编程那点事编程那点事

专注编程入门及提高
探究程序员职业规划之道!

elasticsearch启动报错:Unable to process Jar entry [META-INF/versions/9/module-info.class] from Jar [jar:file:log4j-api-2.11.1.jar!/] for annotations

从字面上来说,就是无法处理log4j-api-2.11.1.jar的注解,就是说在当前的开发环境下,elasticsearch包含的log4j-api-2.11.1.jar版本过高了。

再贴下相信的报错吧:

严重: Unable to process Jar entry [META-INF/versions/9/module-info.class] from Jar [jar:file:/F:/Repository/org/apache/logging/log4j/log4j-api/2.11.1/log4j-api-2.11.1.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19
at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:133)
at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:60)
at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:209)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:119)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2134)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:2010)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1976)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1961)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1319)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

我的解决方法是,修改pom文件,elasticsearch-rest-high-level-client排除log4j-api,再加上一个低版本的log4j-api,具体代码如下:

<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-high-level-client</artifactId>
    <version>6.5.3</version>
    <exclusions>
        <exclusion>
            <artifactId>log4j-api</artifactId>
            <groupId>org.apache.logging.log4j</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.6.2</version>
</dependency>

为什么是2.6.2呢?因为我本地最低的log4j-api版本是2.6.2,我从2.11.1开始往下版本替换,只有2.6.2没有报错。

log4j-api本地仓库

未经允许不得转载: 技术文章 » Java编程 » elasticsearch启动报错:Unable to process Jar entry [META-INF/versions/9/module-info.class] from Jar [jar:file:log4j-api-2.11.1.jar!/] for annotations

专注编程入门及提高,探究程序员职业规划之道!