org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15 - Tomcat 7, JDK incompatibilty? [duplicate]

StackOverflow https://stackoverflow.com/questions/23484098

Pregunta

I tried upgrading to Java 8. When starting our tomcat7 server, with a Java 7-compiled .war file, I get the mysteriously error below.

Should I expect this to work? This post says tomcat 7 should work with 1.6 and up. I can't tell if Tomcat is to blame, or the .war. Switching out different Java versions I get:

  • JDK 7.45 installed - works (same version used to compile .war)
  • JDK 7.55 installed - fails as below
  • JDK 8.05 installed - fails as below

Is tomcat to blame, or the .war?

Caused by: 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:2032)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1923)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1891)
        at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1877)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1270)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:345)
        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:5161)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
¿Fue útil?

Solución

I was seeing this error with Tomcat 7.0.26.

To answer your question, Tomcat is to blame: https://issues.apache.org/bugzilla/show_bug.cgi?id=53735

Upgrading to version 7.0.53 fixed it for me (according to the linked issue, the fix should be in 7.0.30 and later).

Otros consejos

I also faced this problem. I followed the error and I foud out I needed to upgrade to the latest version our maven dependency for ICU4J jar.

And the error is gone now:

  <dependency>
     <groupId>com.ibm.icu</groupId>
     <artifactId>icu4j</artifactId>
     <version>56.1</version>
  </dependency>

I had Java 8 on my computer, but I wanted to run my Tomcat using Java 7.

The following solution worked for me.

In %CATALINA_HOME%\bin\ (E.g.: C:\Tomcat\bin) add setenv.bat having the following content:

@echo off
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_03
set JRE_HOME=%JAVA_HOME%\jre
exit /B 0

When you run startup.bat, the following calls happen:

startup.bat
     |
     └── catalina.bat
               |
               └── setenv.bat
  • see:

    if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome
    call "%CATALINA_BASE%\bin\setenv.bat"
    
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top