Org.Apache.Tomcat.Util.Bcel.Classfile.Classformatexception: Invalid Byte Tag in Constant Pool: 15

org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15

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.

Invalid byte tag in constant pool: 19 error message

Tomcat 8.0 has reached End of Life and should not be used!

The replacement is Tomcat 8.5 (implementing the same specifications as Tomcat 8.0) or Tomcat 9.0 (newer versions of specifications). See "Migration Guide" at tomcat.apache.org.

org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:97)

The BCEL library here is used to parse class files when Tomcat scans for annotations. The version that you are using does not support some features in class file format of Java 8, and thus fails when trying to parse the file.

Your options:

  1. Ignore.
  2. Upgrade Tomcat.
  3. Exclude those jars from annotation scanning. (See the official Tomcat FAQ → Performance → How do I make Tomcat start up faster?).

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

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).

org.apache.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19

I suspect this is caused by one of the tools in the tool chain (incorrectly) trying to load classes from the META-INF/versions/java9 directory in the log4j-api jar.

Can you use a version of BCEL that is “multi -version jar-aware” and doesn’t try to do this?



Related Topics



Leave a reply



Submit