I’m trying to run my (seam and) wicket app on an embedded jetty server.
I get the following exception:
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:366)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)
... 28 more
However, the LoggerFactory class is on my classpath. I tested this as follows:
public class StartJetty {
public static void main(String[] args) throws Exception {
ILoggerFactory fac = LoggerFactory.getILoggerFactory(); //this works!
Server server = new Server();
...
Complete class:
public class StartJetty {
public static void main(String[] args) throws Exception {
Logger log = LoggerFactory.getLogger(StartJetty.class);
Server server = new Server();
SocketConnector connector = new SocketConnector();
connector.setMaxIdleTime(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(8090);
server.setConnectors(new Connector[] { connector });
WebAppContext bb = new WebAppContext();
bb.setParentLoaderPriority(true);
bb.setServer(server);
bb.setContextPath("/wicket");
bb.setWar("C:/wicket/exploded-archives/wicket.war");
server.setHandler(bb);
try {
server.start();
while (System.in.available() == 0) {
Thread.sleep(1000);
}
server.stop();
server.join();
} catch (Throwable e) {
e.printStackTrace();
System.exit(100);
}
}
}
1 – update to jetty 7 or jetty 8, your using jetty 6 by the looks of it and that is getting quite gray behind the ears…we are working on jetty-9 at this point (jetty7 if you want servlet 2.5 and jetty8 if you want servlet 3.0 support)
2 – a webapp executes in an isolated classloader so what you are seeing is that working correctly, you need to set the parent class loader priority on the webapp context that you are creating, or use the server/system mechanism to expose just those org.slf4j classes.
See http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading for more information on classloading in jetty.