奇怪的java.lang.ArrayIndexOutOfBounds在码头启动时抛出的异常

2022-09-04 05:31:15

每当我部署码头应用程序时,我都会遇到此问题。看起来像一些或类坏了。jar

  • 同事编译完全相同的代码,不会遇到问题。即使部署到同一台计算机。(我们使用和gitmaven)
  • 删除本地 maven 存储库并重新构建没有帮助。~/.m2
  • 可以在本地运行相同的码头应用程序,而不会出现任何问题。
  • 我最初的怀疑是有些坏了。已尝试,但未找到任何内容。jarjar tvf $every_jar

任何想法如何调试这个?看起来真的很神秘,我怀疑是一些文件被损坏了。

Stack trace:
2014-10-21 13:29:25.123:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,file:/XYZ/},/XYZ/webapps/root
javax.servlet.ServletException: jersey-serlvet
        at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:553)
        at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:344)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:39)
        at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
        at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:494)
        at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:141)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:145)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:56)
        at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:615)
        at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:540)
        at org.eclipse.jetty.util.Scanner.scan(Scanner.java:403)
        at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:337)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:121)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:555)
        at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:230)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:81)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
        at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:96)
        at org.eclipse.jetty.server.Server.doStart(Server.java:282)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1274)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:473)
        at org.eclipse.jetty.start.Main.start(Main.java:615)
        at org.eclipse.jetty.start.Main.main(Main.java:96)

其次

Caused by:
java.lang.ArrayIndexOutOfBoundsException: 6241
        at org.objectweb.asm.ClassReader.<init>(Unknown Source)
        at org.objectweb.asm.ClassReader.<init>(Unknown Source)
        at org.objectweb.asm.ClassReader.<init>(Unknown Source)
        at com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess(AnnotationScannerListener.java:133)
        at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner$1.f(FileSchemeScanner.java:86)
        at com.sun.jersey.core.util.Closing.f(Closing.java:71)
        at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scanDirectory(FileSchemeScanner.java:83)
        at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scanDirectory(FileSchemeScanner.java:80)
        at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scanDirectory(FileSchemeScanner.java:80)
        at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scan(FileSchemeScanner.java:71)
        at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:223)
        at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:139)
        at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:80)
        at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
        at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
        at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
        at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:700)

答案 1

对于您的2个错误..

javax.servlet.ServletException: jersey-serlvet

这意味着您的WEB-INF/web.xml

至于这个..

java.lang.ArrayIndexOutOfBoundsException: 6241
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)

当使用具有较新编译的Java字节码的旧版本时,我见过类似的。asm.jar

  • 对于 Java 15 字节码,请使用 asm 7.3.1+
  • 对于 Java 14 字节码,请使用 asm 7.2+
  • 对于 Java 13 字节码,请使用 asm 7.1+
  • 对于 Java 12 字节码,请使用 asm 7.1+
  • 对于 Java 11 字节码,请使用 asm 7.0+
  • 对于 Java 10 字节码,请使用 asm 6.1+
  • 对于 Java 9 字节码,请使用 asm 6.0+
  • 对于 Java 8 字节码,请使用 asm 5.0.1+
  • 对于 Java 6 或 Java 7 字节码,(如果必须,请使用 asm 3.1,但要知道 asm 5.x 在这里也可以工作)

确保您的 (或 ) 是最新的。asm.jarorg.objectweb.asm.jar

有一个稍微不太常见的问题,即类本身是坏的。有时在一个JDK(如IBM)中编译,然后在另一个Java(如Sun / Oracle)上运行的类中看到。

一个真实的例子是icu4j-2.6.1.jar及其com/ibm/icu/impl/data/LocaleElements_zh__PINYIN.class jar条目


答案 2

使用较新版本的码头专家插件。

更多信息 --> Bug 419801 - 升级到 asm5 for jdk8

所以,像这样编辑你的:pom.xml

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.0.M2</version>
</plugin>

请注意,groupId 是 “org.eclipse.jetty”。


推荐