Home > Java > javaTutorial > body text

How to Fix \'Invalid Byte Tag Exception\' in Tomcat 7 when Upgrading to Java 8?

DDD
Release: 2024-10-28 15:26:02
Original
778 people have browsed it

 How to Fix

Invalid Byte Tag Exception in Tomcat 7 with Java 8

When porting a web application from Tomcat 7 and Java 7 to another server running Tomcat 7 and Java 8, an error may occur during startup:

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

This exception stems from BCEL, the Java bytecode engineering library used by Tomcat. In particular, annotation scanning (with metadata-complete="true" in web.xml) can trigger issues due to BCEL's inability to process certain Java 8 byte codes.

Solutions:

1. Disable Annotation Scanning:

If annotation scanning is not essential, it can be disabled by setting metadata-complete="false" in web.xml.

2. Tomcat 7.0.53 or Later:

Tomcat 7.0.53 and subsequent releases include an updated compiler with improved Java 8 support. Upgrading to these versions should resolve the exception.

3. Skip Java 8 JARs for Annotation Scanning (Advanced):

If annotation scanning is required and the web application is not Java 8 based, add the following line to /etc/tomcat7/catalina.properties:

junit.jar,junit-*.jar,ant-launcher.jar,\jfxrt.jar,nashorn.jar
Copy after login

This line instructs Tomcat to ignore specific Java 8 JARs during annotation scanning.

The above is the detailed content of How to Fix \'Invalid Byte Tag Exception\' in Tomcat 7 when Upgrading to Java 8?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!