我在Jetty-9.3.3环境中使用带有Spring框架4.3.5的Jersey-2.25.1。我的操作系统是Centos 7和JDK 8.在部署期间,我收到以下错误:
注意:仅当在pom.xml中添加了jersey-spring3依赖项时,才会发生以下错误。
Failed startup of context o.e.j.w.WebAppContext@5d37aa0f{/test-service,file:///.../test-service/,STARTING}
java.lang.RuntimeException: Error scanning entry module-info.class from jar file:///.../test-service/WEB-INF/lib/asm-all-repackaged-2.5.0-b32.jar
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:925)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:842)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:545)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
Caused by:
java.lang.IllegalArgumentException
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 org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:988)
at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:970)
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:921)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:842)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:163)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:545)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
Jetty的/lib/annotations/asm-5.0.1.jar和asm-commons-5.0.1.jar或者jersey-spring3.jar是否有问题?
答案 0 :(得分:5)
我查看了module-info.class文件
$ javap -v ./module-info.class
...
class org.glassfish.hk2.external.org.objectweb.asm.all.debug.module-info
minor version: 0
major version: 53
因此,它是用java 9编译的,它是new module system in java 9的一部分。
无论如何,扫描此文件没有用(特别是使用java 8)。
我通过从Jetty注释扫描中排除asm-all-repackaged.jar
来修复此问题:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.0.v20161208</version>
<configuration>
<webApp>
...
<webInfIncludeJarPattern>.*/^(asm-all-repackaged)[^/]*\.jar$</webInfIncludeJarPattern>
</webApp>
</configuration>
</plugin>