阿帕奇阿波罗 NoClassDefFoundError

Apache Apollo NoClassDefFoundError

当我在 linux (Debian) 上启动 Apache Apollo(1.7.1) 时,出现以下错误:

警告 |失败球衣:java.lang.NoClassDefFoundError:com/sun/jersey/server/impl/application/DeferredResourceConfig java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig

更多详情:

Loading configuration file '/home/xavier/workspace/apache-apollo-1.7.1/bin/mybroker/etc/apollo.xml'.
INFO  | OS     : Linux 3.16.0-4-amd64 (Debian GNU/Linux 8.2 (jessie))
INFO  | JVM    : OpenJDK 64-Bit Server VM 1.7.0_91 (Oracle Corporation)
INFO  | Apollo : 1.7.1 (at: /home/xavier/workspace/apache-apollo-1.7.1)
INFO  | OS is restricting the open file limit to: 50000
INFO  | Starting store: leveldb store at /home/xavier/workspace/apache-apollo-1.7.1/bin/mybroker/data
INFO  | Accepting connections at: tcp://0.0.0.0:61613
INFO  | Accepting connections at: tls://0.0.0.0:61614
INFO  | Accepting connections at: ws://0.0.0.0:61623/
INFO  | Accepting connections at: wss://0.0.0.0:61624/
INFO  | virtual host startup is waiting on store startup
**WARN  | FAILED jersey: java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig
java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig**
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
    at java.lang.Class.getConstructor0(Class.java:2895)
    at java.lang.Class.newInstance(Class.java:354)
    at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1059)
    at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:916)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:496)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:326)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:742)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:258)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1233)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:701)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:475)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
    at org.eclipse.jetty.server.Server.doStart(Server.java:272)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.apache.activemq.apollo.broker.jetty.JettyWebServer$$anonfun$_start.apply$mcV$sp(JettyWebServer.scala:270)
    at org.fusesource.hawtdispatch.package$$anon.run(hawtdispatch.scala:357)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.server.impl.application.DeferredResourceConfig
    at java.net.URLClassLoader.run(URLClassLoader.java:363)
    at java.net.URLClassLoader.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 java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 25 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access00(ZipFile.java:56)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:679)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:415)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at sun.misc.Resource.getBytes(Resource.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:444)
    at java.net.URLClassLoader.access0(URLClassLoader.java:71)
    at java.net.URLClassLoader.run(URLClassLoader.java:361)
    ... 30 more
WARN  | FAILED o.e.j.w.WebAppContext{/,file:/home/xavier/workspace/apache-apollo-1.7.1/bin/mybroker/tmp/webapp-resources/},/home/xavier/workspace/apache-apollo-1.7.1/bin/mybroker/tmp/webapp-resources: java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig
java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
    at java.lang.Class.getConstructor0(Class.java:2895)
    at java.lang.Class.newInstance(Class.java:354)
    at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1059)
    at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:916)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:496)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:326)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:742)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:258)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1233)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:701)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:475)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
    at org.eclipse.jetty.server.Server.doStart(Server.java:272)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.apache.activemq.apollo.broker.jetty.JettyWebServer$$anonfun$_start.apply$mcV$sp(JettyWebServer.scala:270)
    at org.fusesource.hawtdispatch.package$$anon.run(hawtdispatch.scala:357)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.server.impl.application.DeferredResourceConfig
    at java.net.URLClassLoader.run(URLClassLoader.java:363)
    at java.net.URLClassLoader.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 java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 25 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access00(ZipFile.java:56)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:679)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:415)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at sun.misc.Resource.getBytes(Resource.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:444)
    at java.net.URLClassLoader.access0(URLClassLoader.java:71)
    at java.net.URLClassLoader.run(URLClassLoader.java:361)
    ... 30 more
WARN  | FAILED org.eclipse.jetty.server.handler.HandlerList@427631b9: java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig
java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
    at java.lang.Class.getConstructor0(Class.java:2895)
    at java.lang.Class.newInstance(Class.java:354)
    at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1059)
    at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:916)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:496)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:326)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:742)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:258)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1233)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:701)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:475)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
    at org.eclipse.jetty.server.Server.doStart(Server.java:272)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.apache.activemq.apollo.broker.jetty.JettyWebServer$$anonfun$_start.apply$mcV$sp(JettyWebServer.scala:270)
    at org.fusesource.hawtdispatch.package$$anon.run(hawtdispatch.scala:357)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.server.impl.application.DeferredResourceConfig
    at java.net.URLClassLoader.run(URLClassLoader.java:363)
    at java.net.URLClassLoader.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 java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 25 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access00(ZipFile.java:56)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:679)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:415)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at sun.misc.Resource.getBytes(Resource.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:444)
    at java.net.URLClassLoader.access0(URLClassLoader.java:71)
    at java.net.URLClassLoader.run(URLClassLoader.java:361)
    ... 30 more
WARN  | FAILED org.eclipse.jetty.server.Server@28f2146a: java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig
java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2595)
    at java.lang.Class.getConstructor0(Class.java:2895)
    at java.lang.Class.newInstance(Class.java:354)
    at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1059)
    at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:916)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:496)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:326)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:742)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:258)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1233)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:701)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:475)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
    at org.eclipse.jetty.server.Server.doStart(Server.java:272)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.apache.activemq.apollo.broker.jetty.JettyWebServer$$anonfun$_start.apply$mcV$sp(JettyWebServer.scala:270)
    at org.fusesource.hawtdispatch.package$$anon.run(hawtdispatch.scala:357)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.server.impl.application.DeferredResourceConfig
    at java.net.URLClassLoader.run(URLClassLoader.java:363)
    at java.net.URLClassLoader.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 java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 25 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access00(ZipFile.java:56)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:679)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:415)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at sun.misc.Resource.getBytes(Resource.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:444)
    at java.net.URLClassLoader.access0(URLClassLoader.java:71)
    at java.net.URLClassLoader.run(URLClassLoader.java:361)
    ... 30 more
WARN  | java.lang.NoClassDefFoundError: com/sun/jersey/server/impl/application/DeferredResourceConfig
INFO  | virtual host startup is no longer waiting.  It waited a total of 1 seconds.
INFO  | broker startup is waiting on start jetty webserver

有人可以帮忙吗?

查看堆栈跟踪,我会说它试图加载 类 来自的 jar 文件之一有问题:

...
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access00(ZipFile.java:56)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:679)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:415)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at sun.misc.Resource.getBytes(Resource.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:444)
...

这可能是一个损坏的文件,或者可能是一个超过 4GB 的文件 (Reading ZIP file gives an 'invalid LOC header' Exception)。

我会检查你下载的包是否正确,是否正确解压。