Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-329

ClassFormatException when compile template with latest JDK8 (b114)

    Details

    • Workaround Description:
      Hide

      Use Janino compiler, which can be done with these steps:

      • Add -Ddrools.dialect.java.compiler=JANINO to JVM System properties
      • Add Janino to classpath. With maven it can be done by adding this dependency into pom.xml:

        <dependency>
          <groupId>org.codehaus.janino</groupId>
          <artifactId>janino</artifactId>
          <version>2.5.16</version>
         </dependency>
        

      Show
      Use Janino compiler, which can be done with these steps: Add -Ddrools.dialect.java.compiler=JANINO to JVM System properties Add Janino to classpath. With maven it can be done by adding this dependency into pom.xml: <dependency> <groupId>org.codehaus.janino</groupId> <artifactId>janino</artifactId> <version>2.5.16</version> </dependency>
    • Bugzilla Update:
      Perform

      Description

      When trying to run code for compile templates with latest JDK8 (For instance this example https://github.com/droolsjbpm/drools/blob/master/drools-examples/src/main/java/org/drools/examples/templates/SimpleRuleTemplateExample.java )
      it will throw an exception like this:

      Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: wrong class format
      	at org.drools.template.parser.DefaultTemplateRuleBase.readRule(DefaultTemplateRuleBase.java:148)
      	at org.drools.template.parser.DefaultTemplateRuleBase.<init>(DefaultTemplateRuleBase.java:62)
      	at org.drools.template.parser.TemplateDataListener.<init>(TemplateDataListener.java:74)
      	at org.drools.decisiontable.ExternalSpreadsheetCompiler.compile(ExternalSpreadsheetCompiler.java:95)
      	at org.drools.decisiontable.ExternalSpreadsheetCompiler.compile(ExternalSpreadsheetCompiler.java:81)
      	at org.drools.examples.templates.SimpleRuleTemplateExample.buildKBase(SimpleRuleTemplateExample.java:84)
      	at org.drools.examples.templates.SimpleRuleTemplateExample.executeExample(SimpleRuleTemplateExample.java:49)
      	at org.drools.examples.templates.SimpleRuleTemplateExample.main(SimpleRuleTemplateExample.java:43)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      Caused by: java.lang.RuntimeException: wrong class format
      	at org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:263)
      	at org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:203)
      	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:102)
      	at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
      	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
      	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1188)
      	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromVariantTypeSignature(LookupEnvironment.java:1244)
      	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeArgumentsFromSignature(LookupEnvironment.java:1031)
      	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1193)
      	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethod(BinaryTypeBinding.java:495)
      	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createMethods(BinaryTypeBinding.java:577)
      	at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:327)
      	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:640)
      	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:619)
      	at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:295)
      	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:133)
      	at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:183)
      	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findImport(CompilationUnitScope.java:465)
      	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findSingleImport(CompilationUnitScope.java:519)
      	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInImports(CompilationUnitScope.java:368)
      	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:444)
      	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:752)
      	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:464)
      	at org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:389)
      	at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:49)
      	at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:371)
      	at org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:46)
      	at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:102)
      	at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:1006)
      	at org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:842)
      	at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:831)
      	at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:441)
      	at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:419)
      	at org.drools.template.parser.DefaultTemplateRuleBase.readRule(DefaultTemplateRuleBase.java:139)
      	... 12 more
      Caused by: org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
      	at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:372)
      	at org.drools.commons.jci.compilers.EclipseJavaCompiler$2.createNameEnvironmentAnswer(EclipseJavaCompiler.java:287)
      	at org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:258)
      	... 45 more
      

      Workaround, which worked for me is to switch to Janino compiler (See Workaround description)

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            lijia387 Li Jia added a comment -

            Hello,

            When can we expect a fix for this issue? Our product want to support JDK8. It become a blocking issue now.

            Thanks,
            Li

            Show
            lijia387 Li Jia added a comment - Hello, When can we expect a fix for this issue? Our product want to support JDK8. It become a blocking issue now. Thanks, Li
            Hide
            jira-bugzilla-migration RH Bugzilla Integration added a comment -

            Ryan Zhang <rzhang@redhat.com> changed the Status of bug 1078146 from MODIFIED to ON_QA

            Show
            jira-bugzilla-migration RH Bugzilla Integration added a comment - Ryan Zhang <rzhang@redhat.com> changed the Status of bug 1078146 from MODIFIED to ON_QA
            Hide
            joel.njanga Joel Njanga added a comment - - edited

            Version 4.4.1 of org.eclipse.jdt.core.compiler:ecj fixes this for us too. We are using Drools 5.0.1 and Jdk1.8u31.
            However, we can't wait until this ticket is officially resolved.
            Thanks.

            Show
            joel.njanga Joel Njanga added a comment - - edited Version 4.4.1 of org.eclipse.jdt.core.compiler:ecj fixes this for us too. We are using Drools 5.0.1 and Jdk1.8u31. However, we can't wait until this ticket is officially resolved. Thanks.
            Hide
            jira-bugzilla-migration RH Bugzilla Integration added a comment -

            Tibor Zimanyi <tzimanyi@redhat.com> changed the Status of bug 1078146 from ON_QA to VERIFIED

            Show
            jira-bugzilla-migration RH Bugzilla Integration added a comment - Tibor Zimanyi <tzimanyi@redhat.com> changed the Status of bug 1078146 from ON_QA to VERIFIED
            Hide
            tonyhujboss tony hu added a comment -

            Is there any timeline for the fix? We are upgrading our production to 1.8 by blocked due to this bug. Any update is highly appreciated!

            Show
            tonyhujboss tony hu added a comment - Is there any timeline for the fix? We are upgrading our production to 1.8 by blocked due to this bug. Any update is highly appreciated!

              People

              • Assignee:
                mark.proctor Mark Proctor
                Reporter:
                mposolda Marek Posolda
              • Votes:
                8 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Development