【发布时间】:2013-07-14 13:36:34
【问题描述】:
我正在尝试设置一个嵌入式 jetty 9 实例,该实例从 .war 文件中提取注释。
到目前为止,它已成功运行,例如GeoServer.war(通过将 ExtractWars 设置为 True),但是当它拾取包含带注释的 servlet 的 WebChat.war 时,我在 AnnotationsConfiguration 类上得到了一个 ClassNotFound。 p>
在示例战争中,我在其 web.xml 中添加了 'metadata-complete="false"',并且我在码头服务器中添加了下一位
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
希望知道如何解决类加载问题..
提前致谢
【问题讨论】:
标签: jakarta-ee jetty war embedded-jetty servlet-3.0