SpringBoot 1.2在关闭时抛出NoClassDefFoundError

时间:2014-12-30 13:32:40

标签: java spring jetty spring-boot

Exception in thread "Thread-2" java.lang.NoClassDefFoundError: org/eclipse/jetty/util/FutureCallback
        at org.eclipse.jetty.server.AbstractConnector.shutdown(AbstractConnector.java:285)
        at org.eclipse.jetty.server.AbstractNetworkConnector.shutdown(AbstractNetworkConnector.java:108)
        at org.eclipse.jetty.server.ServerConnector.shutdown(ServerConnector.java:341)
        at org.eclipse.jetty.server.Server.doStop(Server.java:404)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
        at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainer.stop(JettyEmbeddedServletContainer.java:149)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.stopAndReleaseEmbeddedServletContainer(EmbeddedWebApplicationContext.java:277)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:142)
        at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:804)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.FutureCallback
        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
        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:425)
        at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:170)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:136)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 9 more
Caused by: java.util.zip.ZipException: invalid block type
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
        at org.springframework.boot.loader.jar.ZipInflaterInputStream.read(ZipInflaterInputStream.java:52)
        at sun.misc.Resource.getBytes(Resource.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:444)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        ... 16 more

依赖关系:

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-amqp</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j</artifactId>
    </dependency>

1.1.3和1.1.4也发生了同样的错误。

如果从POM中看不清楚我正在使用嵌入式jetty9服务器。也使用Java7。当我ctr-c服务器时出现错误。

1 个答案:

答案 0 :(得分:3)

线条......

Caused by: java.util.zip.ZipException: invalid block type
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)

...意味着你有一个糟糕的jar文件。

现在,要清楚,这只意味着你的JAR文件在Spring Boot加载org.eclipse.jetty.util.FutureCallback类的时候是不好的。

这个坏jar文件的起源可能是从一开始(例如在本地maven存储库中有一个错误的副本)或在运行时(通常被视为一个与你的实时运行时jar和类混淆的二次进程)。

至于修复此问题,我将首先分析您使用的jar文件(尝试将它们完全解压缩到临时目录中)。甚至可能在本地存储库目录中强制重新下载jar(甚至可以查看dependency:purge-local-repository maven插件目标以获取详细信息)