[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] IllegalStateException when starting embedded Jetty with JNDI resources
|
This fixed it, but I'm not sure why. I ended up changing my Resources
to EnvEntries, and I had a stale <resource-ref> in web.xml that I removed.
On 6/3/2011 9:31 AM, David Ehrmann wrote:
Here's the exception that I get when I do server.start():
java.lang.IllegalStateException: Nothing to bind for name
com.test.Foo/default
I'm tying to run embedded Jetty from a static main method. I provide
it a default servlet, web.xml, a context path, and a directory for
files to serve. I try to register two JNDI resources (Bar and Baz,
both implement the Foo interface), but I end up getting an exception.
I'm sure I'm doing something wrong. Here's the code:
System.setProperty("java.naming.factory.url.pkgs",
"org.eclipse.jetty.jndi");
System.setProperty("java.naming.factory.initial",
"org.eclipse.jetty.jndi.InitialContextFactory");
Server server = new Server(8080);
server.setAttribute("org.eclipse.jetty.webapp.configuration", new
String[] {
"org.eclipse.jetty.webapp.WebInfConfiguration",
"org.eclipse.jetty.webapp.WebXmlConfiguration",
"org.eclipse.jetty.webapp.MetaInfConfiguration",
"org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.plus.webapp.EnvConfiguration",
"org.eclipse.jetty.plus.webapp.PlusConfiguration",
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
"org.eclipse.jetty.webapp.TagLibConfiguration",
});
WebAppContext root = new WebAppContext();
root.setResourceBase("./ROOT");
root.setDescriptor("/ROOT/WEB-INF/web.xml");
root.setContextPath("/");
root.addServlet(DefaultServlet.class, "/");
new org.eclipse.jetty.plus.jndi.Resource(root,
Foo.class.getCanonicalName() + "/bar", new Bar());
new org.eclipse.jetty.plus.jndi.Resource(root,
Foo.class.getCanonicalName() + "/baz", new Baz());
server.setHandler(root);
server.start();