Gerrit Brink
Gerrit Brink

Reputation: 997

Tomcat 7 Annotation scanner and JDK 8 with -parameters compiler flag exceptions

I am compiling my classfiles with JDK 8 with the -parameters flag which preserves the parameter names and makes them available via reflection. Tomcat 7 seems to have issues with my class files.

Aug 13, 2014 8:31:32 AM org.apache.catalina.startup.ContextConfig processAnnotationsFile
SEVERE: Unable to process file [/home/rex/apache-tomcat-7.0.54/webapps/ROOT/WEB-INF/classes/mod/test/TestData.class] for annotations
java.io.EOFException
        at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:340)
        at org.apache.tomcat.util.bcel.classfile.Utility.swallowMethodParameters(Utility.java:797)
        at org.apache.tomcat.util.bcel.classfile.Attribute.readAttribute(Attribute.java:171)
        at org.apache.tomcat.util.bcel.classfile.FieldOrMethod.<init>(FieldOrMethod.java:57)
        at org.apache.tomcat.util.bcel.classfile.Method.<init>(Method.java:71)
        at org.apache.tomcat.util.bcel.classfile.ClassParser.readMethods(ClassParser.java:267)
        at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:127)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2058)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2033)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2026)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2026)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1291)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)

I am using Tomcat 7.0.54 and JDK 8u5 x64 Any assistance will be much appreciated :)

Upvotes: 2

Views: 14326

Answers (3)

Faycel Abidi
Faycel Abidi

Reputation: 11

I have got the same problem and I resolved it without upgrading tomcat version as the following:

  1. Changing the jaassist version ( i used the version 3.20.0-GA and i changed it to 3.18.1-GA)

  2. adding some args to maven compiler plugin

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${plugin.compiler.version}</version>
        <configuration>
            <source>${project.build.javaVersion}</source>
            <target>${project.build.javaVersion}</target>
            <forceJavacCompilerUse>true</forceJavacCompilerUse>
            <fork>true</fork>
            <compilerArgument>-proc:none</compilerArgument>             
        </configuration>
    </plugin>
    
  3. adding the tag metadata-complete="true" to the web.xml

Upvotes: 1

Gerrit Brink
Gerrit Brink

Reputation: 997

Confirmed to be fixed in Tomcat 7.0.56

See changelog for Tomcat 7.0.56 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html

Also tested this locally and it fixed my problems

Upvotes: 2

rmuller
rmuller

Reputation: 12859

That is correct, you have to disable annotation processing, see this question org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15 for more information.

Upvotes: 1

Related Questions