今天系统部署到新的测试机上面出现一个问题
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:55) at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:176) at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:85) at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2042) at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1988) at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1958) at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1912) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1157) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:779) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:306) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5150) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1092) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1834) 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:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
搜索了一下,有网友遇到过相似的情况,这个问题的原因是有些jar中增加了jdk9特性Module,Package信息,在这些包中可以找到module-info.class,其jdk版本号也对应1.9。比如我项目中受影响的jar是apiguardian-api-1.1.0.jar和stax-ex-1.8.jar,还有jaxb-runtime-2.3.1.jar等等,而这些包中其他的class文件版本号并没有升级到1.9,而tomcat启动时,会尝试解析这些类,解析到module-info.class时,导致了报错。
解决办法是建议将tomcat升级到8.0最新版本,如8.5,9.0