Jetty在关机时抛出NoClassDefFoundError:org / eclipse / jetty / util / FutureCallback

时间:2015-01-27 12:11:40

标签: java jetty noclassdeffounderror shutdown

我们的maven build在jetty关闭的构建结束时抛出一个我不明白的NoClassDefFoundError。有没有人知道这是从哪里来的,以及如何解决它?

以下是来自pom文件的依赖项:

<dependencies>
    <dependency>
      <groupId>com.restfuse</groupId>
      <artifactId>com.eclipsesource.restfuse</artifactId>
      <version>1.0.0</version>
    </dependency>

    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.4</version>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>1.7.7</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.easytesting</groupId>
      <artifactId>fest-assert</artifactId>
      <version>1.4</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.pe-international</groupId>
      <artifactId>bom.model</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.jayway.restassured</groupId>
      <artifactId>rest-assured</artifactId>
      <version>2.3.4</version>
    </dependency>
    <dependency>
      <groupId>com.jayway.restassured</groupId>
      <artifactId>json-path</artifactId>
      <version>2.3.4</version>
    </dependency>
    <dependency>
      <groupId>com.jayway.restassured</groupId>
      <artifactId>xml-path</artifactId>
      <version>2.3.4</version>
    </dependency>
  </dependencies>

Jetty conf:

<!-- Start Jetty -->
      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.2.2.v20140723</version>
        <configuration>
          <war>${basedir}/target/bla.war</war>
          <httpConnector>
            <port>8088</port>
          </httpConnector>
          <webApp>
            <contextPath>/bla</contextPath>
          </webApp>
          <systemProperties>
            <systemProperty>
              <name>config.dir</name>
              <value>${basedir}/target/config.dir</value>
            </systemProperty>
          </systemProperties>
          <stopKey>fooStopBla</stopKey>
          <stopPort>8089</stopPort>
        </configuration>
        <executions>
          <execution>
            <id>start-jetty</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>deploy-war</goal>
            </goals>
            <configuration>
              <scanIntervalSeconds>0</scanIntervalSeconds>
              <daemon>true</daemon>
            </configuration>
          </execution>
          <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

这是mvn依赖:tree

[INFO] com.company:our.endpoint.test:jar:1.0.0-SNAPSHOT
[INFO] +- com.restfuse:com.eclipsesource.restfuse:jar:1.0.0:compile
[INFO] |  +- org.mortbay.jetty:jetty-j2se6:jar:6.1.26:compile
[INFO] |  |  \- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO] |  |     +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
[INFO] |  |     \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile
[INFO] |  \- com.sun.jersey:jersey-bundle:jar:1.9.1:compile
[INFO] |     \- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.7:test
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.7:test
[INFO] +- org.easytesting:fest-assert:jar:1.4:test
[INFO] |  \- org.easytesting:fest-util:jar:1.1.6:test
[INFO] +- com.company:our.model:jar:1.0.0-SNAPSHOT:test
[INFO] |  +- org.jscience:jscience:jar:4.3.1:test
[INFO] |  |  \- org.javolution:javolution:jar:5.2.3:test
[INFO] |  +- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.6.5:test
[INFO] |  +- org.springframework:spring-beans:jar:4.1.1.RELEASE:test
[INFO] |  |  \- org.springframework:spring-core:jar:4.1.1.RELEASE:test
[INFO] |  +- org.springframework:spring-context:jar:4.1.1.RELEASE:test
[INFO] |  |  +- org.springframework:spring-aop:jar:4.1.1.RELEASE:test
[INFO] |  |  |  \- aopalliance:aopalliance:jar:1.0:test
[INFO] |  |  \- org.springframework:spring-expression:jar:4.1.1.RELEASE:test
[INFO] |  \- com.google.guava:guava:jar:15.0:test
[INFO] +- com.jayway.restassured:rest-assured:jar:2.3.4:compile
[INFO] |  +- org.codehaus.groovy:groovy:jar:2.3.6:compile
[INFO] |  +- org.codehaus.groovy:groovy-xml:jar:2.3.6:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO] |  |  +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] |  |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.3.5:compile
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:compile
[INFO] |  \- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile
[INFO] +- com.jayway.restassured:json-path:jar:2.3.4:compile
[INFO] |  +- org.codehaus.groovy:groovy-json:jar:2.3.6:compile
[INFO] |  \- com.jayway.restassured:rest-assured-common:jar:2.3.4:compile
[INFO] +- com.jayway.restassured:xml-path:jar:2.3.4:compile
[INFO] |  \- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] \- org.mockito:mockito-all:jar:1.9.5:test

这是我们的堆栈跟踪:

2015-01-27 13:04:57.810:WARN:oejuc.AbstractLifeCycle:Thread-1: FAILED org.eclipse.jetty.maven.plugin.JettyServer@6dd82486: java.lang.NoClassDefFoundError: org/eclipse/jetty/util/FutureCallback
java.lang.NoClassDefFoundError: org/eclipse/jetty/util/FutureCallback
        at org.eclipse.jetty.server.AbstractConnector.shutdown(AbstractConnector.java:284)
        at org.eclipse.jetty.server.AbstractNetworkConnector.shutdown(AbstractNetworkConnector.java:108)
        at org.eclipse.jetty.server.ServerConnector.shutdown(ServerConnector.java:298)
        at org.eclipse.jetty.maven.plugin.MavenServerConnector.shutdown(MavenServerConnector.java:140)
        at org.eclipse.jetty.server.Server.doStop(Server.java:397)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
        at org.eclipse.jetty.util.thread.ShutdownThread.run(ShutdownThread.java:132)
Caused by:
java.lang.ClassNotFoundException: org.eclipse.jetty.util.FutureCallback
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
        at org.eclipse.jetty.server.AbstractConnector.shutdown(AbstractConnector.java:284)
        at org.eclipse.jetty.server.AbstractNetworkConnector.shutdown(AbstractNetworkConnector.java:108)
        at org.eclipse.jetty.server.ServerConnector.shutdown(ServerConnector.java:298)
        at org.eclipse.jetty.maven.plugin.MavenServerConnector.shutdown(MavenServerConnector.java:140)
        at org.eclipse.jetty.server.Server.doStop(Server.java:397)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
        at org.eclipse.jetty.util.thread.ShutdownThread.run(ShutdownThread.java:132)
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: org/eclipse/jetty/util/FutureCallback
        at org.eclipse.jetty.server.AbstractConnector.shutdown(AbstractConnector.java:284)
        at org.eclipse.jetty.server.AbstractNetworkConnector.shutdown(AbstractNetworkConnector.java:108)
        at org.eclipse.jetty.server.ServerConnector.shutdown(ServerConnector.java:298)
        at org.eclipse.jetty.maven.plugin.MavenServerConnector.shutdown(MavenServerConnector.java:140)
        at org.eclipse.jetty.server.Server.doStop(Server.java:397)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
        at org.eclipse.jetty.util.thread.ShutdownThread.run(ShutdownThread.java:132)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.FutureCallback
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
        ... 7 more

有时堆栈跟踪会有所不同,而且会出现这种情况:

2015-01-28 10:12:55.630:WARN:oejuc.AbstractLifeCycle:ShutdownMonitor: FAILED org.eclipse.jetty.servlet.ServletHandler@3accac55: java.lang.NoClassDefFoundError: org/eclipse/jetty/util/LazyList
java.lang.NoClassDefFoundError: org/eclipse/jetty/util/LazyList
    at org.eclipse.jetty.servlet.ServletHandler.doStop(ServletHandler.java:266)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
    at org.eclipse.jetty.security.SecurityHandler.doStop(SecurityHandler.java:411)
    at org.eclipse.jetty.security.ConstraintSecurityHandler.doStop(ConstraintSecurityHandler.java:457)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
    at org.eclipse.jetty.server.session.SessionHandler.doStop(SessionHandler.java:127)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
    at org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:835)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:215)
    at org.eclipse.jetty.webapp.WebAppContext.doStop(WebAppContext.java:529)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStop(JettyWebAppContext.java:388)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)
    at org.eclipse.jetty.server.Server.doStop(Server.java:456)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
    at org.eclipse.jetty.server.ShutdownMonitor$ShutdownMonitorRunnable.stopLifeCycles(ShutdownMonitor.java:273)
    at org.eclipse.jetty.server.ShutdownMonitor$ShutdownMonitorRunnable.run(ShutdownMonitor.java:172)

6 个答案:

答案 0 :(得分:21)

请注意,一些其他示例将使您向jersey-container-jetty-http添加maven依赖项,其中包括可能较旧版本的jetty http。如果您已经拥有jetty-server dep,请删除该依赖项。在你的pom文件中。

答案 1 :(得分:6)

您的环境中似乎有两个版本的Jetty。

您的mvn dependency:tree<scope>compile</scope>依赖项中显示以下内容。

[INFO] com.company:our.endpoint.test:jar:1.0.0-SNAPSHOT
[INFO] +- com.restfuse:com.eclipsesource.restfuse:jar:1.0.0:compile
[INFO] |  +- org.mortbay.jetty:jetty-j2se6:jar:6.1.26:compile
[INFO] |  |  \- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO] |  |     +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
[INFO] |  |     \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile

这里有两个问题。

首先,restfuse似乎是旧的,非常古老,并且想要Jetty 6.1.26。 (这个版本的Jetty在2007年是EOL /生命终结)

其次,当jetty-maven-plugin正在运行时,此版本可能会影响应用程序的行为。

为Jetty 6添加一个排除项,然后尝试一下。

<dependency>
  <groupId>com.restfuse</groupId>
  <artifactId>com.eclipsesource.restfuse</artifactId>
  <version>1.0.0</version>
  <exclusions>
    <exclusion>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-j2se6</artifactId>
    </exclusion>
  </exclusions>
</dependency>

但请记住,restfuse 1.0.0可能不适用于Jetty 9.如果是这样,你会想要追逐已为Jetty 9更新的更新版本的restfuse。

答案 2 :(得分:4)

我在9.2.3修正了这个问题。请参阅错误报告https://bugs.eclipse.org/bugs/show_bug.cgi?id=438500

答案 3 :(得分:1)

我收到此错误,因为目录“target / classes”不存在。解决这个问题的一种快速方法是简单地创建一个src / main / java文件夹,然后在那里创建任何类(甚至是一个空类)。

答案 4 :(得分:1)

我使用eclipse Jetty插件时遇到了类似的问题。通过添加适当的依赖项解决了它。有关详细信息,请访问 - http://eclipse-jetty.github.io/faq.html

答案 5 :(得分:0)

我遇到了同样的问题,并且我使用的是码头版本9.4.12.v20180830 之后,我将版本更改为9.4.12.RC2,一切正常