Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] IllegalStateException when starting embedded Jetty with JNDI resources

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[] {

WebAppContext root = new WebAppContext();



root.addServlet(DefaultServlet.class, "/");

new, Foo.class.getCanonicalName() + "/bar", new Bar()); new, Foo.class.getCanonicalName() + "/baz", new Baz());



Back to the top