java 码头抛出NoClassDefFoundError:org/eclipse/jetty/util/关闭时的未来回调

kcrjzv8t  于 2022-12-28  发布在  Java
关注(0)|答案(7)|浏览(150)

我们的maven构建在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>

码头配置:

<!-- 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)
hs1ihplo

hs1ihplo1#

注意,一些rest示例会让您添加一个maven依赖项到jersey-container-jetty-http,其中可能包含一个较旧版本的jetty http。如果您的pom文件中已经有一个jetty-server dep.,请删除该依赖项。

ehxuflar

ehxuflar2#

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

这里有两个问题。
首先,restfuse看起来很老,非常老,需要Jetty 6.1.26。(此版本的Jetty早在2007年就已停产)
第二,当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的较新版本。

insrf1ej

insrf1ej3#

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

dfty9e19

dfty9e194#

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

jfewjypa

jfewjypa5#

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

xqk2d5yq

xqk2d5yq6#

我遇到了同样的问题,我使用的是jetty版本9. 4. 12. v20180830,之后我将版本更改为版本9. 4. 12. rc2,一切正常

lymgl2op

lymgl2op7#

一个Maven重新加载的项目修复了它给我。

相关问题