解决Tomcat启动报错:严重:Unable?to?process?Jar?entry?[META-INF/versions/9/module-info.class]


    目录
  • 报错
  • 解决
  • 总结

    报错
    启动有报错,但不影响使用,本着不放过任何一个错误的原则来解决下
    报错代码:
    
    严重: Unable to process Jar entry [META-INF/versions/9/module-info.class] from Jar [jar:file:/G:/maven/repository/org/apache/logging/log4j/log4j-api/2.16.0/log4j-api-2.16.0.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:97)
        at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:54)
        at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:174)
        at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:83)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2119)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1981)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1942)
        at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1927)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1332)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:888)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:388)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5522)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:679)
        at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1966)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    解决
    因为不影响使用,所以我们可以在启动Tomcat时需要跳过检查的jar包。
    通过tomcat.util.scan.StandardJarScanFilter.jarsToSkip参数实现
    打开如下目录文件
    
    tomcat\conf\catalina.properties
    tomcat.util.scan.StandardJarScanFilter.jarsToSkip节点增加log4j-api-2.16.0.jar
    
    重启启动tomcat无报错。
    总结
    以上为个人经验,希望能给大家一个参考,也希望大家多多支持电脑手机教程网。