Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 7 - Servlet 3.0: Invalid byte tag in constant pool

  • tomcat 7.0.16
  • Java 1.6.0_22
  • CentOS 5.6

I just switched the web.xml to servlet 3.0 (from a app running 2.4 previously) and now I'm seeing the following error (turned on fine logging for org.apache.tomcat.util):

mtyson  FINE: Scanning JAR [file:/usr/java/jdk1.6.0_22/jre/lib/ext/jcharset.jar] from classpath
mtyson  Jul 19, 2011 10:04:40 AM org.apache.catalina.startup.HostConfig deployDirectory
mtyson  SEVERE: Error deploying web application directory ROOT
mtyson  org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 60

UPDATE: Just Tried tomcat 7.0.19 - same results

like image 259
mtyson Avatar asked Jul 19 '11 18:07

mtyson


4 Answers

Adding

metadata-complete="true" 

to your web.xml should sort the issue

<web-app version="3.0"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         metadata-complete="true">

This tells tomcat not to scan classes for annotations: https://web.archive.org/web/20180510163848/http://www.tomcatexpert.com/blog/2011/10/12/how-use-fragments-and-annotations-configure-your-web-application

like image 55
KeithM Avatar answered Nov 09 '22 21:11

KeithM


It may not be your issue, but mine was the same as this one -- an old version of com.ibm.icu:icu4j. I solved the problem by changing my build configuration to exclude the older transitive dependencies and explicitly depending upon the latest version (4.8).

like image 31
James A Wilson Avatar answered Nov 09 '22 20:11

James A Wilson


Thanks James A Wilson for your answer - updating icu4j as you suggested worked for me and allows me to keep version="3.0" in my web.xml (which I prefer for the long run).

icu4j 2.6.1 was the version which did not work, upgrading to the NEXT version 3.4.4 will solve this problem. I did NOT go to the latest version of icu4j (49.1) because it is 4MB larger than version 3.4.4.

Here is a Maven configuration snippet to lock in your transitive dependency version (without adding an explicit dependency):

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.ibm.icu</groupId>
            <artifactId>icu4j</artifactId>
            <version>3.4.4</version>
        </dependency>
    </dependencies>
</dependencyManagement>
like image 19
Steve Jones Avatar answered Nov 09 '22 20:11

Steve Jones


This turned out to be an incompatible jasper jar being included in the build, conflicting with the jasper.jar in tomcat 7.

like image 3
mtyson Avatar answered Nov 09 '22 19:11

mtyson