Ahhh I see, in the ServletServer class that I included in that project > Line 41, I call (setContextPath(ServletContext);) if I omit that it works! So the bug is deffinetly related to setting the context in the Adapter, rather than setting it in the webservers addGrizzlyAdapter String[] parameter. If were going to mandate that the server be passed the adapter and the context when its added, We should probably remove the setContextPath from ServletAdapter class. On the other hand, could remove the array of strings from the addGrizzlyAdapter and relocate that to the ServletAdapter and make an addContext(); class there. (I know I harp on this :) but it just seems like better design IMO)
--Richard
________________________________
From: Richard Corsale <igf1_at_yahoo.com>
To: users_at_grizzly.dev.java.net; Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Sent: Friday, February 27, 2009 3:58:27 PM
Subject: Re: issue 460? -- note
Ok Im uploading attached to this message a test case, its a netbeans project, and its just as simple as I could make it. There are 3 files here + I use the server 1.9.7 the latest upload from the 24th
the 3 files I have here are:
Main: the execution point
ServletServer: this aggregates the adapters into one bean (I have also tested with servlet and grizzly adapters created in the Main file, its exactly the same)
testServelt: well this is just the servlet that prints outPut
Problem:
take a look at the Main file, there you will see that I load 6 instances of testServlet, 3 that extend the root context /test1, /test2, /test3 . All of these are accessable no problem. Now look at the last three
that I load: /test/test4, /test/test5, /test/test6 ONLY test4 works. The other subContexts /test/test > 4 fail with the message:
Resource Not Found
________________________________
From: Survivant 00 <survivant00_at_gmail.com>
To: users_at_grizzly.dev.java.net
Sent: Friday, February 27, 2009 2:46:47 PM
Subject: Re: issue 460? -- note
we be easier if I had a testcase that I could run.
2009/2/27 Richard Corsale <igf1_at_yahoo.com>
When I attempt to load adapters as follows:
(assume that "Server" is a grizzlyWebServer )
-----------------------
this.Server.addGrizzlyAdapter(sa, new String[]{ContextPath});
in a loop which is read from the hashmap containing the Grizzly adapter and its coresponding context (as one context is specific to one servlet in this instance)
output:
DEBUG >> API.GrizzlyHarness : About to load servlet: /OortCloud/test2 to root folder: .
DEBUG >> API.GrizzlyHarness : About to load servlet: /OortCloud/test3 to root folder: .
DEBUG >> API.GrizzlyHarness : About to load servlet: /OortCloud/debug to root folder: .
DEBUG >> API.GrizzlyHarness : About to load servlet: /OortCloud/test to root folder: .
Only the first adapter gets installed, the subsequent adapters are not loaded (at least to their specified context). So I can only acess test2 if I specify a RootFolder I can access all
can someone onfirm
----- Original Message ----
From: Richard Corsale <igf1_at_yahoo.com>
To: users_at_grizzly.dev.java.net
Sent: Friday, February 27, 2009 1:42:41 PM
Subject: issue 460?
ohhh see I was adding contexts one at a time, in a loop rather than all
at once (we really should encapsulate the context in the adapter as a
constructor param, since its mandatory for and relative to the
grizzlyadapter :) )
heres how I have been doing it:
This
is the bean that holds servlets/GrizzlyAdapters and their relitive
contexts, I refer to this as a ServletServer as it makes more sence (to
me) to load servlets into a server.
-----------------------------------
public class ServletServer{
private HashMap<String, ServletAdapter> ServletAdapters = new HashMap<String, ServletAdapter>();
public ServletServer(Servlet ServletClass, String ServletContext) {
addServlet(ServletContext, ServletClass);
}
public ServletServer() {
}
/**
* Adds a new servlet to this server, will overwrite an existing instance if
* the contexts collide.
*
* @param Context <b the context/uri for this servlet >
* @param ServletInstance
*/
public void addServlet(String ServletContext, Servlet ServletInstance){
ServletAdapter sa = new ServletAdapter();
sa.setServletInstance(ServletInstance);
// sa.setRootFolder(OortFileUtils.instance.getObjectsDirectory(ServletInstance));
sa.setHandleStaticResources(true);
sa.addInitParameter("default-encoding", "UTF-8");
sa.setContextPath(ServletContext);
sa.setProperty("load-on-startup","1");
this.ServletAdapters.put(ServletContext, sa);
}
public HashMap<String, ServletAdapter> getServletAdapters() {
return ServletAdapters;
}
}
And here is the controller code that loads these adapters into the GrizzlyWebserver from the bean
-------------------------------------------------
public void doLoadServletServer(ServletServer servletServer){
HashMap<String, ServletAdapter> servletStore = servletServer.getServletAdapters();
for(String context: servletStore.keySet()){
ServletAdapter sa = servletStore.get(context);
// String RootFolder = OortFileUtils.getObjectsDirectory(servletStore.get(context));
// sa.setRootFolder(RootFolder);
loadServletAdapter(sa);
}
}
private void loadServletAdapter(ServletAdapter sa){
OortDebug.out.print("About to load servlet: "+sa.getContextPath()+" to root folder: "+sa.getRootFolder() , this);
this.Server.addGrizzlyAdapter(sa, new String[]{sa.getContextPath()});
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net