Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5320

groovyc ant task cannot compile Servlet using Java EE 6 reference API libaries (results in ClassFormatError Missing Code attribute)

    XMLWordPrintableJSON

Details

    Description

      Compiling a simple servlet against the Java EE 6 reference APIs results in a groovyc compilation failure. I have attached a project with both a Java Servlet and a Groovy Servlet.

      The Java compiler works ok but the groovyc fails. Using Maven's eclipse-groovy-plugin also works ok. It seems that the groovyc compiler is introspecting the class in a different way than the maven eclipse-groovy-compiler.

      Buildfile: X:\workspaces\test\krasmussen\GroovyBug\GroovyBug\build.xml
      
      clean:
      
      init:
      
      compile:
          [mkdir] Created dir: X:\workspaces\test\krasmussen\GroovyBug\GroovyBug\build\classes\main
          [javac] Compiling 1 source file to X:\workspaces\test\krasmussen\GroovyBug\GroovyBug\build\classes\main
          [javac] X:\workspaces\test\krasmussen\GroovyBug\GroovyBug\src\main\java\com\acme\test\servlet\JavaServlet.java
        [groovyc] Compiling 1 source file to X:\workspaces\test\krasmussen\GroovyBug\GroovyBug\build\classes\main
        [groovyc] X:\workspaces\test\krasmussen\GroovyBug\GroovyBug\src\main\groovy\com\acme\test\servlet\GroovyServlet.groovy
      
        [groovyc] >>> a serious error occurred: javax/servlet/ServletException : Missing Code attribute
        [groovyc] >>> stacktrace:
        [groovyc] java.lang.ClassFormatError: javax/servlet/ServletException : Missing Code attribute
        [groovyc]     at java.lang.ClassLoader.defineClass1(Native Method)
        [groovyc]     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        [groovyc]     at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        [groovyc]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        [groovyc]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        [groovyc]     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        [groovyc]     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        [groovyc]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        [groovyc]     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        [groovyc]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        [groovyc]     at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
        [groovyc]     at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:696)
        [groovyc]     at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:564)
        [groovyc]     at org.codehaus.groovy.control.ResolveVisitor.resolveToClass(ResolveVisitor.java:709)
        [groovyc]     at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:275)
        [groovyc]     at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1241)
        [groovyc]     at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:148)
        [groovyc]     at org.codehaus.groovy.control.CompilationUnit$9.call(CompilationUnit.java:605)
        [groovyc]     at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:843)
        [groovyc]     at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:548)
        [groovyc]     at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:497)
        [groovyc]     at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:480)
        [groovyc]     at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:60)
        [groovyc]     at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:216)
        [groovyc]     at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:149)
        [groovyc]     at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.j
      ava:179)
        [groovyc]     at org.codehaus.groovy.ant.FileSystemCompilerFacade.main(FileSystemCompilerFacade.java:27)
      
      BUILD FAILED
      X:\workspaces\test\krasmussen\GroovyBug\GroovyBug\build.xml:42: Forked groovyc returned error code: 1
      

      Maven build

      X:\workspaces\test\krasmussen\GroovyBug>mvn clean compile
      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building CPMS Parent Module 3.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ parent-pom ---
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 0.760s
      [INFO] Finished at: Mon Feb 20 14:58:45 CST 2012
      [INFO] Final Memory: 28M/64M
      [INFO] ------------------------------------------------------------------------
      X:\workspaces\test\krasmussen\GroovyBug>mvn clean compile
      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building CPMS Parent Module 3.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ groovy-bug ---
      [INFO]
      [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ groovy-bug ---
      [INFO] Using 'UTF-8' encoding to copy filtered resources.
      [INFO] skip non existing resourceDirectory X:\workspaces\test\krasmussen\GroovyBug\src\main\resources
      [INFO]
      [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ groovy-bug ---
      [INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
      [INFO] Compiling 2 source files to X:\workspaces\test\krasmussen\GroovyBug\target\classes
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 3.421s
      [INFO] Finished at: Mon Feb 20 14:59:20 CST 2012
      [INFO] Final Memory: 15M/64M
      [INFO] ------------------------------------------------------------------------
      X:\workspaces\test\krasmussen\GroovyBug>
      

      Attachments

        1. GroovyBug.zip
          1.35 MB
          Kirk Rasmussen

        Activity

          People

            Unassigned Unassigned
            krasmussen Kirk Rasmussen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: