The Bad Programmer

Deploy Grails 3 Application to Tomcat 7.0.37

I had some issues getting a Grails 3 application to deploy to Tomcat 7.0.37. I finally figured out that the problem was that I was running Tomcat with a 1.8 JDK. If you try to deploy a Grails 3 application to Tomcat 7.0.37 running with a Java 1.8 JDK you get an error that looks like this when the application is deploying:

Caused by: org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 18
    at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(
    at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(
    at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(
    at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(
    at org.apache.catalina.startup.ContextConfig.processAnnotations(
    at org.apache.catalina.startup.ContextConfig.webConfig(
    at org.apache.catalina.startup.ContextConfig.configureStart(
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(
    at org.apache.catalina.core.StandardContext.startInternal(
    at org.apache.catalina.util.LifecycleBase.start(

I should note that my app was compiled with source compatibility set at 1.7 so it should have had no problem running under a 1.8 JDK. I have had no other problems running Tomcat 7.0.37 under Java 1.8.

I have no idea if later dot releases of Tomcat 7 have the same problem but it is definitely a problem with Tomcat 7.0.37. From looking at the stack trace it looks like there is some deploy time processing of annotations and whatever is doing that processing doesn’t like running under Java 1.8.

Here is a table of my testing with Tomcat 7.0.37 and an Grails 3 application:

JDK Source Deploys?
1.8 1.7 Nope
1.8 1.8 Nope
1.7 1.7 Yes!
1.7 1.8 Nope, however it is obvious this one won’t work, just including for completeness