我正試圖在嵌入式碼頭服務器上運行我的(seam和)wicket應用程序。Wicket和嵌入式碼頭 - classNotFoundException
我得到以下異常:
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
然而,的LoggerFactory類是在我的類路徑中。我測試了這個如下:
public class StartJetty {
public static void main(String[] args) throws Exception {
ILoggerFactory fac = LoggerFactory.getILoggerFactory(); //this works!
Server server = new Server();
...
完整的類:
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);
}
}
}
「設置父Web應用程序上下文中的類加載器優先級「 - >這不起作用,除非你意味着別的東西比webAppContext.setParentLoaderPriority(true); – Fortega 2012-03-22 12:31:55
需要看到一些代碼,然後瞭解你的設置是什麼,因爲這是常見的解決方案 – 2012-03-22 12:49:29
我編輯了問題以包含完整的代碼。檢查以上... – Fortega 2012-03-22 12:51:53