Home  >  Article  >  Java  >  Why am I Getting \"Invalid Byte Tag in Constant Pool: 15\" Exception in Tomcat 7 with Java 8?

Why am I Getting \"Invalid Byte Tag in Constant Pool: 15\" Exception in Tomcat 7 with Java 8?

Linda Hamilton
Linda HamiltonOriginal
2024-10-27 08:40:03930browse

Why am I Getting

"Invalid Byte Tag in Constant Pool: 15" Exception in Tomcat 7 with Java 8

Tomcat 7 is officially compatible with Java 8. However, when migrating a webapp from Tomcat 7 with Java 6 to another Tomcat 7 server with Java 8, users may encounter the following exception:

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

Possible Causes

This exception occurs due to BCEL (Byte Code Engineering Library) issues in Tomcat 7 with Java 8. BCEL encounters difficulties processing the new Java 8 byte codes, especially when annotation scanning is enabled (metadata-complete="true" in web.xml).

Solutions

No Annotation Scanning:

If annotation scanning is not utilized, the issue can be resolved by updating Tomcat 7 to release 7.0.53 or later, which includes an updated compiler with improved Java 8 support.

Annotation Scanning:

When annotation scanning is enabled, there are two alternatives:

  • Exclude Problem Libraries: Add the following line to /etc/tomcat7/catalina.properties:
junit.jar,junit-*.jar,ant-launcher.jar,\
jfxrt.jar,nashorn.jar

This will instruct Tomcat to skip scanning the indicated libraries.

  • Disable Annotation Scanning: Remove "metadata-complete="true" from web.xml to disable annotation scanning.

Additional Notes:

  • This particular issue arose with Tomcat 7.0.28 on Debian 7.6 with Oracle JDK 8_25.
  • The "official answer" that Tomcat 7 is compatible with Java 8 remains valid. However, BCEL issues may arise when annotation scanning is enabled.

The above is the detailed content of Why am I Getting \"Invalid Byte Tag in Constant Pool: 15\" Exception in Tomcat 7 with Java 8?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn