org.apache.tomcat.util.bcel.classfile.ClassFormatException:常量池中的无效字节标签:15 [英] org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15
问题描述
Tomcat成功启动,但在日志 catalina.out
我得到:
org.apache.tomcat.util.bcel.classfile.ClassFormatException :常量池中的无效字节标记:15
在org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)
在org.apache.tomcat.util.bcel .classfile.ConstantPool。< init>(ConstantPool.java:60)
在org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:209)
在org。 apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:119)
在org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2049)
在org。 apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1931)
在org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1899)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1885)
在org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1281)
在org.apache。 catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
在org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:346)
在org.apache.catalina.util。 LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
在org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
在org.apache.catalina.core.StandardContext.startInternal( StandardContext.java:5172)
在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java: 899)
在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
在org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)
在org.apache.catalina.startup.HostConfig $ DeployDirectory.run(HostConfig.java:1618)
在java。 util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)
在java.util.concurrent.FutureTask.run(FutureTask.java:266)
在java.util.concurrent.ThreadPoolExecutor。 runWorker(ThreadPoolExecutor.java:1142)
在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)
在java.lang.Thread.run(Thread.java:745)
可能是什么问题?
正式答案是Tomcat 7在Java 8上运行,请参阅
http://tomcat.apache.org/whichversion.html (Java版本6及更高版本)。
但是,如果注释扫描已启用(web.xml中的metadata-complete =true)有一些问题由于BCEL(不能处理新的Java 8字节代码)。你会得到例外(至少与Tomcat 7.0.28):
严重:无法处理Jar条目[jdk / nashorn /internal/objects/NativeString.class]从Jar [jar:file:/usr/lib/jvm/jdk1.8.0_5/jre/lib/ext/nashorn.jar!/]注释
org.apache。 tomcat.util.bcel.classfile.ClassFormatException:常量池中的无效字节标记:15
在org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)
如果不使用注释扫描,一切正常,起始版本7.0.53(更新的编译器与更好的Java 8支持)。
(更新2014-10-17)
如果您的使用注释扫描和 你自己的代码不是基于Java 8的,另一个解决方案是在 /etc/tomcat7/catalina.properties
中添加以下行(ant- launcher.jar所以属性的一部分 tomcat.util.scan.DefaultJarScanner.jarsToSkip
): jfxrt.jar,nashorn。 jar
在Debian 7.6上使用Tomcat 7.0.28和Oracle JDK 8_25进行测试。
I'm porting a webapp from Tomcat 7 to another server with Tomcat 7 but with Java 8.
Tomcat starts successfully but in log catalina.out
I get:
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15
at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)
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:2049)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1931)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1899)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1885)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1281)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:346)
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:5172)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
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:618)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)
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)
What could be the problem?
The "offical answer" is that Tomcat 7 runs on Java 8, see http://tomcat.apache.org/whichversion.html ("Java version 6 and later").
However, if annotation scanning is enabled (metadata-complete="true" in web.xml) there are some issues due to BCEL (not able to process the new Java 8 byte codes). You will get exceptions like (at least with Tomcat 7.0.28):
SEVERE: Unable to process Jar entry [jdk/nashorn/internal/objects/NativeString.class] from Jar [jar:file:/usr/lib/jvm/jdk1.8.0_5/jre/lib/ext/nashorn.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15
at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)
If not using annotation scanning, everything works fine, starting release 7.0.53 (updated compiler with better Java 8 support).
(UPDATE 2014-10-17)
If your are using annotation scanning and your own code is not Java 8 based, another solution is to add the following line in /etc/tomcat7/catalina.properties
(text added after "ant-launcher.jar" so part of property tomcat.util.scan.DefaultJarScanner.jarsToSkip
):
junit.jar,junit-*.jar,ant-launcher.jar,\
jfxrt.jar,nashorn.jar
Tested with Tomcat 7.0.28 and Oracle JDK 8_25 on Debian 7.6.
这篇关于org.apache.tomcat.util.bcel.classfile.ClassFormatException:常量池中的无效字节标签:15的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!