【问题标题】:embedded jetty 9 classNotFound for AnnotationConfiguration in WebAppContext.doStartWebAppContext.doStart 中 AnnotationConfiguration 的嵌入式 jetty 9 classNotFound
【发布时间】: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


    【解决方案1】:

    感谢您查看我的问题。

    我发现了问题;

    我在端口 8443 上运行码头服务器,而不是在 8080 端口上。但是使用初始化的 webchat.html 文件

    $(document).ready(
    function() {
          ws = new WebSocket("ws://localhost:8443/WebChat/map");
    

    但它应该是 WSS 协议,因为它通过 8443 是安全的。即

    $(document).ready(
    function() {
          ws = new WebSocket("wss://localhost:8443/WebChat/map");
    

    事实证明它可以在不将 setConfigurationClasses 设置为

    的情况下工作
      mAppProvider.setConfigurationClasses( new String[]{
        AnnotationConfiguration.class.toString(),
        WebInfConfiguration.class.toString(),
        PlusConfiguration.class.toString(),
        FragmentConfiguration.class.toString(),            
      });
    

    希望有人对此有所帮助。

    【讨论】:

      猜你喜欢
      • 2014-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多