Jetty throw NoClassDefFoundError: org/eclipse/jetty/util/FutureCallback on shutdown

2022-09-03 00:01:21

我们的专家构建在码头关闭的构建结束时抛出了一个我不理解的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>

码头会议:

<!-- 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 依赖项:树

[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)

答案 1

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


答案 2

看起来您的环境中同时有 2 个版本的 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

这里有2个问题。

首先,是看起来很旧,很旧,想要Jetty 6.1.26。(这个版本的Jetty在2007年是EOL/End-of-Life)restfuse

其次,此版本可能会影响应用程序在运行时的行为。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>

但请记住,重新填充 1.0.0 可能不适用于 Jetty 9。如果是这样,您将需要追逐已针对Jetty 9更新的较新版本的respause。


推荐