Jetty启动报Error scanning entry META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class
近日在项目中集成Elasticsearch后,Jetty启动报错。
错误日志如下:
Suppressed: |java.lang.RuntimeException: Error scanning entry META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class from jar file:///data/program/capital/cloud/work/jetty-0.0.0.0-16201-capital-cloud.war-_capital-cloud-any-/webapp/WEB-INF/lib/log4j-api-2.11.1.jar | at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:891) | at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:837) | at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:159) | at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:462) | at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673) | at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591) | at java.lang.Thread.run(Thread.java:748) |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:959) | at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:940) | at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:887) | at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:837) | at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:159) | at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:462) | at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673) | at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591) | at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.RuntimeException: Error scanning entry META-INF/versions/9/module-info.class from jar file:///data/program/capital/cloud/work/jetty-0.0.0.0-16201-capital-cloud.war-_capital-cloud-any-/webapp/WEB-INF/lib/log4j-api-2.11.1.jar at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:891) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:837) at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:159) at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:462) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591) at java.lang.Thread.run(Thread.java:748) 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:959) at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:940) at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:887) at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:837) at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:159) at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:462) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591) at java.lang.Thread.run(Thread.java:748)
于是翻江倒海的四处查解决方案,有的说把jar包里面的version删掉再重新打包更改版本号,试过不起作用。
后来又找历史发布公告,发现是jetty版本不兼容引起的,升级到jetty-9.4.8.v20171121即可完美解决问题。
查找的一些资源网站:
2. https://blog.csdn.net/baidu_34036884/article/details/80151963
3. 关于jdk9的兼容问题:
https://github.com/eclipse/jetty.project/issues/1797
https://github.com/eclipse/jetty.project/pull/1801
4. 历史版本发布记录:
https://www.eclipse.org/lists/jetty-announce/2017/Nov/index.php
9.4.7针对jdk9开始兼容:https://www.eclipse.org/lists/jetty-announce/msg00111.html
9.4.8针对jdk9兼容优化:https://www.eclipse.org/lists/jetty-announce/msg00114.html
5. Jetty文档:
https://www.eclipse.org/jetty/documentation/9.3.27.v20190418/
6. Jetty历史服务下载地址
https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/