SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #21  
Old 05-14-2010, 04:28 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
I found some simple jetty example code and can get it to cleanly build but how do I create a .war file using NetBeans? I've searched for hours and the best I can find is:

- NetBeans does it for you, look in the dist directory (I did, it created a .jar file)

- Right click and choose export to .war (I right clicked everywhere I could think of, where do I right click?)

I found some cryptic remarks about a "web project" but I can't find a way in NetBeans to select a "web project".
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #22  
Old 05-14-2010, 04:43 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
I found some simple jetty example code and can get it to cleanly build but how do I create a .war file using NetBeans? I've searched for hours and the best I can find is:

- NetBeans does it for you, look in the dist directory (I did, it created a .jar file)

- Right click and choose export to .war (I right clicked everywhere I could think of, where do I right click?)

I found some cryptic remarks about a "web project" but I can't find a way in NetBeans to select a "web project".
Tom, I haven't used netbeans in years, and to be honest, when I had used it, I didn't create web apps. But, in eclipse the process is as follows...

When you create a project (File -> New) you create a Dynamic Web Application. Then you add your code, and then to create the .war file, you select the project folder and you select "File -> Export".

Also, in eclipse (and netbeans too i suspect) you can fully test the servlet by right clicking on the project and selecting "Run As -> Web Application".. this will start a tomcat/jetty instance and allow you to test your servlet.
Reply With Quote
  #23  
Old 05-14-2010, 04:52 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
There's a bunch of web development stuff that's not part of the standard Java SE NetBeans install. Go into Tools > Plugins and you'll see a lot of downloadable add-ons for NetBeans. I'm not too familiar with this stuff but I'm guessing what you want is probably in the Java Web Applications plugin.
__________________
-- Greg
Reply With Quote
  #24  
Old 05-14-2010, 05:15 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by PLUCKYHD View Post
Why do you say that? All of them being in the same jvm is make it easy to communicat between each one or treat them as seperates. It is the clients that are difficult.
Plucky,

Are you saying if they are all in the same JVM data that is the Global Context (added using AddGlobalContext()) are shared between the UI contexts? I thought AddGlobalContext() only worked within the same UI context?

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #25  
Old 05-14-2010, 05:49 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Greg, Sean,

Thanks for the help. I found what I needed by downloading the Web plugin from Tools->Plugins. Now to see if I can get the demo going...
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #26  
Old 05-14-2010, 06:18 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Yikes! the plugin installed OK but when I went to create a new web project I had nothing but trouble.

First it wants to know what type of server I have and there is no choice for jetty. There's Tomcat, Glassfish and a whole bunch of other things, but no jetty.

I chose Glassfish because it also gave me the option to download and install it. The download went OK but as soon as the new project wizard ends it complains that some library "javaee-endorsed-api-6.0" could not be found. I have no idea where to find that.

I feel like a blind man fumbling around...
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #27  
Old 05-14-2010, 09:29 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
Yikes! the plugin installed OK but when I went to create a new web project I had nothing but trouble.

First it wants to know what type of server I have and there is no choice for jetty. There's Tomcat, Glassfish and a whole bunch of other things, but no jetty.

I chose Glassfish because it also gave me the option to download and install it. The download went OK but as soon as the new project wizard ends it complains that some library "javaee-endorsed-api-6.0" could not be found. I have no idea where to find that.

I feel like a blind man fumbling around...
Tom, I'm really surprised that it doesn't have Tomcat installed by default. Tomcat is "the" standard app server. Glassfish is overkill for this. Maybe the tomcat server didn't have a download option because it's installed by default. Both Jetty and Tomcat are app servers and compatible with the java servlet specification. So, if you write and test using tomcat, it will run under jetty. Failing that, you can download tomcat manually and unzip and run it. (likewise with jetty).
Reply With Quote
  #28  
Old 05-14-2010, 09:56 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by tmiranda View Post
Plucky,

Are you saying if they are all in the same JVM data that is the Global Context (added using AddGlobalContext()) are shared between the UI contexts? I thought AddGlobalContext() only worked within the same UI context?

Tom
No the ui's don't intertwine as global context is only used in the ui session.

But if you had a public static array or hashmap in java and a call to add or read it in studio it would contain the same information for extenders,servers, placeshifters they would all have acces to the same object

so for instance if you had a array and added element b from extender bedroom an element c from extender living room and then on the server called to get the values you would get element b and c returned.

As long as you don't initiate a seperate instance in the ui this will hold true.

Cheers
Reply With Quote
  #29  
Old 05-15-2010, 05:02 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by stuckless View Post
Calling the servlet from your client code is pretty easy, just use URLConnection to open a connection to the servlet. You can use http response codes to indicate success or failure (ie, 200 ok - item was accepted, 500 error - item was rejected), etc.
I managed to get a simple .war file to build and do something (I think). I had to download another plugin to get the missing library file.

My next step is to get some java code to talk to the servlet. Where can I find an example of how to use URLConnection?

Thanks for all of your help on this gents.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #30  
Old 05-15-2010, 05:29 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Tom, here's a sample of how to use a url/urlconnection. (please note there is no error checking, etc, this is just the base code)

for the url, you simply, craft your url, with whatever args you need.

Code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;


public class TestURLConnection {
	public static void main(String args[]) throws Exception {
		URL url = new URL("http://feeds.arstechnica.com/arstechnica/everything");
		URLConnection conn = url.openConnection();
		conn.connect();
		if (conn instanceof HttpURLConnection) {
			System.out.println("Connected");
			HttpURLConnection httpConn = (HttpURLConnection) conn;
			if (httpConn.getResponseCode()!=200) {
				System.out.println("Error: " + httpConn.getResponseCode() + "; " + httpConn.getResponseMessage());
				return;
			}

			BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			String line = null;
			while ((line = reader.readLine())!=null) {
				System.out.println("RESPONSE: " + line);
			}
			reader.close();
		}
	}
}
Reply With Quote
  #31  
Old 05-15-2010, 06:12 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Sean,

Don't you ever sleep?

Thanks for the code snippit. How does this interact with the doGet and doPost?

Does the reader.readLine statement get the results of doPost? I don't see the code sending any data to the servlet, is that correct? Would I use reader.writeLine to send something to the servlet?

What I want to do is write a simple test to send some data (preferably non-String) to the servlet and have the servlet send back a response.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #32  
Old 05-15-2010, 06:38 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Tom, I find sleep gets in the way of me getting things done

Here's a snipped of a "TestServlet" that I just created...

Code:
package test.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class TestServlet
 */
public class TestServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public TestServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name = request.getParameter("name");
		if (name==null||name.length()==0) {
			response.sendError(501, "Missing 'name' argument");
		}
		
		response.setContentType("text/plain");
		PrintWriter pw = response.getWriter();
		pw.printf("Hello: %s\n", name);
		pw.flush();
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
here's my web.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>ScratchWeb</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>TestServlet</display-name>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>test.servlet.TestServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/TestServlet</url-pattern>
  </servlet-mapping>
</web-app>
And I invoked it as
Code:
http://localhost:8080/ScratchWeb/TestServlet?name=Sean
and the reply was
Code:
Hello: Sean
The important things to note here is that my doPost() just calls doGet(), so that if the url is invoked using GET or POST, then it behaves the same. My Servlet mapping is /TestServlet (which just happens to be the name of my class, but it doesn't have to be that way).

I hope this gives you a better indication of how the client and server interact.
Reply With Quote
  #33  
Old 05-15-2010, 07:42 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Sean,

OK, that's clearer but...

I thought doGet would get a request and doPost would post a response. I guess that's wrong. What's the difference between doGet and doPost?

In all of the examples I've seen it's been Strings that are being passed as parameters. Can this also be used to pass more complex data like Maps and Arrays?

Does the method that makes a request to the servlet expect a response right away or can it simply make the request and then continue processing?

I am thinking the overall structure of my project should look like this. Comments welcome.

There are three parts;

1. A jetty servlet whose job it is to wait for requests to download podcasts. It also needs to handle "status" requests such as: Is something being downloaded? What's being downloaded? How many items are in the download queue? etc.

2. A runnable class that periodically wakes up, checks for favorite podcasts that have new episodes available, and then for each new episode make a request to the servlet to download it. This runnable class will also need to provide status information such as: How many episodes are availabe for a certain podcast? (I'm not clear on how to do this part. Do I need another servlet that accepts this status info and then suplpies it to methods that request it?)

3. Some methods that can be used by the UI to request a download, get download status, etc.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #34  
Old 05-15-2010, 08:24 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
I thought doGet would get a request and doPost would post a response. I guess that's wrong. What's the difference between doGet and doPost?
GET and POST are part of the HTTP specification and they deal with how the request is invoked. You can read the HTTP spcification if you really need more information, but for now, just treat them as the same.

Quote:
In all of the examples I've seen it's been Strings that are being passed as parameters. Can this also be used to pass more complex data like Maps and Arrays?
URLs are Strings. If you need to pass a map, then you'll need to convert to url paramters, and array the same.

for example, if you call,
http://server/servlet?rssfeed=url&re...H1&channel=CH2

in the doGet, the "getParameter()" behaves like a map in that you can get the named elements 'rssfeed', 'returnitems', by name. But, 'channe' will return an array, because you used the same name 'channel' more than once.

OR, from the client, you can serialize your objects, and then turn them into strings and then deserialize the objects in the servlet (a lot more complex)

Quote:
Does the method that makes a request to the servlet expect a response right away or can it simply make the request and then continue processing?
Requests are synchronous and each request is invoked in its own thread. if you need to continue processing, since start a thread in the servlet or pass the information to a running thread.

Quote:
1. A jetty servlet whose job it is to wait for requests to download podcasts. It also needs to handle "status" requests such as: Is something being downloaded? What's being downloaded? How many items are in the download queue? etc.
You can use the same servlet instance, just pass an arg for the action.. ie, cmd=status, cmd=addpodcast, then then branch on that.
Reply With Quote
  #35  
Old 05-15-2010, 02:20 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
OK, got it. I think I can do what I need to do without serializing.

Next question: When constructing the URL in the method that calls the servlet, how do you obtain the port for the jetty server? Is this just something I need to have the user input during setup?

I think I can assume a hostname of "localhost" for extenders and placeshifters and I think there is a Sage API that gets the hostname for a client. Will this work for Mac and Linux as well?
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #36  
Old 05-15-2010, 02:44 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
OK, got it. I think I can do what I need to do without serializing.

Next question: When constructing the URL in the method that calls the servlet, how do you obtain the port for the jetty server? Is this just something I need to have the user input during setup?

I think I can assume a hostname of "localhost" for extenders and placeshifters and I think there is a Sage API that gets the hostname for a client. Will this work for Mac and Linux as well?
Yeah, the jetty server and port will be a configuration parameter, and there is no easy way to find it out (although sagex api does do it), but you can default to port 8080, which is the default.
Reply With Quote
  #37  
Old 05-15-2010, 03:16 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Sean,

No love. I tried to build and deploy your code (just changed the name) but I get an error 404.

Here is the java and the .xml. The .war file build fine and is placed in the jetty/webapps directory as SagePodcastRecorder.war. The .xml is in the contexts directory as sagepodcastrecorder.xml.

I'm putting the followign into the browser:

Code:
http://harris:8080/SagePodcastRecorder?name=Sean
Do I need to restart Sage/jetty each time I change the .war or .xml?

Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sagepodcastrecorder;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
 *
 * @author Tom Miranda
 */
public class SagePodcastRecorder extends HttpServlet {

        public SagePodcastRecorder() {
            super();
        }

        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name = request.getParameter("name");
		if (name==null||name.length()==0) {
			response.sendError(501, "Missing 'name' argument");
		}

		response.setContentType("text/plain");
		PrintWriter pw = response.getWriter();
		pw.printf("Hello: %s\n", name);
		pw.flush();
	}

}
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>SagePodcastRecorder</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>SagePodcastRecorder</display-name>
    <servlet-name>SagePodcastRecorder</servlet-name>
    <servlet-class>sagepodcastrecorder.SagePodcastRecorder</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>SagePodcastRecorder</servlet-name>
    <url-pattern>/SagePodcastRecorder</url-pattern>
  </servlet-mapping>
</web-app>
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #38  
Old 05-15-2010, 03:35 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
Sean,

No love. I tried to build and deploy your code (just changed the name) but I get an error 404.

Here is the java and the .xml. The .war file build fine and is placed in the jetty/webapps directory as SagePodcastRecorder.war. The .xml is in the contexts directory as sagepodcastrecorder.xml.

I'm putting the followign into the browser:

Code:
http://harris:8080/SagePodcastRecorder?name=Sean
Do I need to restart Sage/jetty each time I change the .war or .xml?

Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sagepodcastrecorder;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
 *
 * @author Tom Miranda
 */
public class SagePodcastRecorder extends HttpServlet {

        public SagePodcastRecorder() {
            super();
        }

        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name = request.getParameter("name");
		if (name==null||name.length()==0) {
			response.sendError(501, "Missing 'name' argument");
		}

		response.setContentType("text/plain");
		PrintWriter pw = response.getWriter();
		pw.printf("Hello: %s\n", name);
		pw.flush();
	}

}
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>SagePodcastRecorder</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>SagePodcastRecorder</display-name>
    <servlet-name>SagePodcastRecorder</servlet-name>
    <servlet-class>sagepodcastrecorder.SagePodcastRecorder</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>SagePodcastRecorder</servlet-name>
    <url-pattern>/SagePodcastRecorder</url-pattern>
  </servlet-mapping>
</web-app>
Tom, 2 things...
1. Take a look at the bmt context xml for the sjq context xml to get an idea of how to create a context file. The xml that that you posted, while is needed, is automatically added to the war file. BUT for jetty to work under sage, it also needs a context file, which is different.

2. When you invoke the url, you have to pass the CONTEXT name in the url (as defined in the context xml file) ie,

Code:
http://harris:8080/YOUR_CONTEXT_NAME/SagePodcastRecorder?name=Sean
Here's the bmt.xml context file.
Code:
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/bmt</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/bmt.war</Set>
  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">true</Set>
  
  <!-- http://docs.codehaus.org/display/JETTY/How+to+Configure+Security+with+Embedded+Jetty -->
  <!-- include security constraints here because the only other place they can be specified
       is in the web.xml file inside the war file -->
  <!-- can the constraints be included in another file we won't overwrite? -->
  <Get name="securityHandler">
    <Set name="userRealm">
      <New class="org.mortbay.jetty.security.HashUserRealm">
        <Set name="name">Metadata Tools Web (BMT)</Set>
        <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
      </New>
    </Set>
    <Set name="checkWelcomeFiles">true</Set>
    <Set name="constraintMappings">
      <Array type="org.mortbay.jetty.security.ConstraintMapping">
        <Item>
          <New class="org.mortbay.jetty.security.ConstraintMapping">
            <Set name="constraint">
              <New class="org.mortbay.jetty.security.Constraint">
                <Set name="name">BASIC</Set>
                <Set name="roles">
                  <Array type="java.lang.String">
                    <Item>user</Item>
                    <Item>admin</Item>
                    <Item>moderator</Item>
                  </Array>
                </Set>
                <Set name="authenticate">true</Set>
              </New>
            </Set>
            <Set name="pathSpec">/*</Set>
          </New>
        </Item>
      </Array>
    </Set>
  </Get>
</Configure>
The security stuff is there in case you want to add authentication to the context.
Reply With Quote
  #39  
Old 05-15-2010, 03:37 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
first, verify that jetty itself is working properly. Try browsing to http://harris:8080. It should give you an 'error' page, but on that page, it will have individual links to all the contexts currently installed.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #40  
Old 05-15-2010, 03:54 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Fuzzy - Jetty is working, I can get bmt to work fine.

Sean - I was wondering why your .xml was so much different from the other example context xml's I've seen. I copied your bmt xml (below) and it still does not work. The only difference is now if I enter http://harris:8080/sagepodcastrecorder I get a "Hello World!" message in the browser.

I thought there might be a difference between SagePodcastRecorder and sagepodcastrecorder so I tried every combination of sagepodcastrecorder/sagepodcastrecorder I could think of.

Code:
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/sagepodcastrecorder</Set>
  <Set name="war">
    <SystemProperty name="jetty.home" default="."/>/webapps/SagePodcastRecorder.war
  </Set>
  <Set name="tempDirectory">
    <SystemProperty name="jetty.home" default="."/>/webapps/SagePodcastRecorder
  </Set>
  <Set name="defaultsDescriptor">
    <SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml
  </Set>
  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">true</Set>
</Configure>
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Replying to Announcement Threads MeInMaui SageTV Customizations 1 07-09-2009 10:49 PM
Number of threads? Stuntman SageTV Beta Test Software 8 11-24-2008 01:00 PM


All times are GMT -6. The time now is 05:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.