我正在尝试设置一个嵌入式 jetty 9 实例,该实例从 .war 文件中获取注释。
到目前为止,它成功地运行了例如 GeoServer.war(通过将 ExtractWars 设置为 True),但是当它拾取包含带注释的 servlet 的 WebChat.war 时,我在AnnotationsConfiguration类上得到了一个ClassNotFound 。
在示例战争中,我将'metadata-complete="false"'添加到其 web.xml,我还将下一位添加到码头服务器
ContextHandlerCollection mHandlers = new ContextHandlerCollection();
String mWebAppDir = ... ;
WebAppProvider mAppProvider = new WebAppProvider();
mAppProvider.setMonitoredDirName( mWebAppDir );
mAppProvider.setDefaultsDescriptor( null );
mAppProvider.setScanInterval(0);
mAppProvider.setExtractWars(true);
mAppProvider.setConfigurationClasses( new String[]{
AnnotationConfiguration.class.toString(),
WebInfConfiguration.class.toString(),
PlusConfiguration.class.toString(),
FragmentConfiguration.class.toString(),
});
DeploymentManager mDeployMgr = new DeploymentManager();
mDeployMgr.addAppProvider( mAppProvider );
mDeployMgr.setContexts( mHandlers );
/* Setup & Run server */
mServer.addBean(mDeployMgr);
mServer.setHandler(mHandlers);
mServer.start();
我将所有 Jetty9 jar(jetty-distribution-9.0.3.v20130506),包括 jar 'websocket-core-9.0.0.M2.jar' 添加到 jetty 服务器项目。IDE 知道AnnotationConfiguration类,但是当 jetty 处理 war 文件时,它带有:
2013-07-16 14:05:36.731:INFO:oejs.Server:main: jetty-9.0.3.v20130506
2013-07-16 14:05:36.753:INFO:oejdp.ScanningAppProvider:main:
Deployment monitor [file:/C:/..../webapps/] at interval 0
2013-07-16 12:57:38.542:WARN:oejw.WebAppContext:main:
Failed startup of context o.e.j.w.WebAppContext@3ac8e6{/WebChat,null,null}
{C:\....\webapps\WebChat.war}
java.lang.ClassNotFoundException: class org.eclipse.jetty.annotations.AnnotationConfiguration
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:100)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:79)
at org.eclipse.jetty.webapp.WebAppContext.loadConfigurations(WebAppContext.java:919)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:420)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:489)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:39)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:495)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:175)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:605)
WebChat.war内容如下:
\chat.html
\css\style.css
\js\jquery-1.3.2.js
\META-INF\MANIFEST.MF
\WEB-INF\classes
\WEB-INF\lib
\WEB-INF\web.xml
\WEB-INF\classes\jettytest
\WEB-INF\classes\jettytest\Feature.class
\WEB-INF\classes\jettytest\FeatureWebSocket.class
\WEB-INF\classes\jettytest\FeatureWebSocketServlet.class
\WEB-INF\lib\websocket-api-9.0.3.v20130506.jar
\WEB-INF\lib\websocket-common-9.0.3.v20130506.jar
\WEB-INF\lib\websocket-core-9.0.0.M2.jar
\WEB-INF\lib\websocket-server-9.0.3.v20130506.jar
\WEB-INF\lib\websocket-servlet-9.0.3.v20130506.jar
希望得到一个线索如何解决类加载问题..
提前谢谢