Can't run Gradle 1.10 due to asm conflict


(neale) #1

I just installed Gradle 1.10 on Win64 with java 1.6.0_30 but every attempt to run it (apart from getting the version info) produces the following asm-related IncompatibleClassChangeError. I’ve not yet created any projects and am calling Gradle from an empty directory but even ‘gradle help’ produces the same error. Deleting the .gradle directory and the local maven repository doesn’t help.

There are plenty of threads about this kind of error but they all seem to be concerned with the transitive dependencies of projects that use Gradle, rather than with Gradle itself.

I must be missing something obvious as I find it hard to believe that Gradle won’t run from a clean install. Any ideas?

$ gradle -v
  ------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------
  Build time:
 2013-12-17 09:28:15 UTC
Build number: none
Revision:
   36ced393628875ff15575fa03d16c1349ffe8bb6
  Groovy:
     1.8.6
Ant:
        Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:
        2.2.0
JVM:
        1.6.0_30 (Sun Microsystems Inc. 0.2-b02-internal, 19.0-b04-internal)
OS:
         Windows 7 6.1 amd64
  $ gradle help --stacktrace
  FAILURE: Build failed with an exception.
  * What went wrong:
Could not generate a proxy class for class org.gradle.invocation.DefaultGradle.
  * Try:
Run with --info or --debug option to get more log output.
  * Exception is:
org.gradle.api.GradleException: Could not generate a proxy class for class org.gradle.invocation.DefaultGradle.
        at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:220)
        at org.gradle.api.internal.AbstractClassGenerator.generate(AbstractClassGenerator.java:49)
        at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)
        at org.gradle.initialization.DefaultGradleLauncherFactory.doNewInstance(DefaultGradleLauncherFactory.java:126)
        at org.gradle.initialization.DefaultGradleLauncherFactory.newInstance(DefaultGradleLauncherFactory.java:95)
        at org.gradle.initialization.DefaultGradleLauncherFactory.newInstance(DefaultGradleLauncherFactory.java:48)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.getLauncher(InProcessBuildActionExecuter.java:58)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:46)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.Main.main(Main.java:37)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected
        at org.gradle.api.internal.AsmBackedClassGenerator$ClassBuilderImpl.addGetter(AsmBackedClassGenerator.java:508)
        at org.gradle.api.internal.AsmBackedClassGenerator$ClassBuilderImpl.addGetter(AsmBackedClassGenerator.java:502)
        at org.gradle.api.internal.AsmBackedClassGenerator$ClassBuilderImpl.mixInDynamicAware(AsmBackedClassGenerator.java:259)
        at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:90)
        ... 25 more

(Peter Niederwieser) #2

It’s certainly not a general problem. One possibility is that you don’t have a clean JDK/JRE install. For example, there might be an ASM Jar in your JDK’s ‘jre/lib’ directory. Or you are executing Gradle with a public JRE that has an ASM Jar in its ‘lib’ directory.


(neale) #3

The JDK is the standard Sun Win64 install. I couldn’t find any jars with ASM in the name.

There is no CLASSPATH env variable set and the PATH looks pretty clean.

Is it possible to dump the Gradle classpath? The --debug option gives the same output as --stacktrace.


(Peter Niederwieser) #4

Gradle uses several class loaders, and I’m not sure what’s the easiest way to print out their class paths. First thing I’d do is to enable verbose class logging (‘export GRADLE_OPTS="-verbose:class"’) and check where the ASM classes are loaded from. Another thing you can try is to attach a debugger.


(neale) #5

Found it. Turns out my ‘standard’ JDK install wasn’t so standard after all. I’d forgotten that it had been patched with DCE VM (we need it for debugging another app). The verbose classpath output contained a reference to dcevm.jar.

For reference, I fixed it by uninstalling DCE VM, running the following Jar Jar Links ant build on the DCE VM jar to rename the packages, then reinstalling it. Both Gradle and the third-party app debugger are working fine now.

Thanks for your help. I’m looking forward to using Gradle - looks like a great tool.

<?xml version="1.0" encoding="UTF-8"?>
<project name="DCEVM Repackaging" default="repackage">
  <target name="repackage">
    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="jarjar-1.4.jar"/>
          <unzip src="dcevm-0.2-win.jar" dest="dcevm"/>
    <jarjar jarfile="dcevm/data/dcevm-repackaged-full.jar">
      <zipfileset src="dcevm/data/dcevm.jar"/>
      <rule pattern="org.objectweb.asm.**" result="at.ssw.asm.@0"/>
    </jarjar>
    <zip destfile="dcevm/data/dcevm-repackaged.jar">
      <zipfileset src="dcevm/data/dcevm.jar" includes="META-INF/MANIFEST.MF"/>
      <zipfileset src="dcevm/data/dcevm-repackaged-full.jar" excludes="META-INF/MANIFEST.MF"/>
    </zip>
    <delete file="dcevm/data/dcevm-repackaged-full.jar"/>
    <delete file="dcevm/data/dcevm.jar"/>
    <move file="dcevm/data/dcevm-repackaged.jar" tofile="dcevm/data/dcevm.jar"/>
          <delete file="dcevm-0.2-win.jar"/>
    <zip destfile="dcevm-0.2-win.jar" basedir="dcevm"/>
          <jarjar jarfile="dcevm-repackaged-full.jar">
      <zipfileset src="dcevm-0.2-win.jar"/>
      <rule pattern="org.objectweb.asm.**" result="at.ssw.asm.@0"/>
    </jarjar>
    <delete file="dcevm-repackaged.jar"/>
    <zip destfile="dcevm-repackaged.jar">
      <zipfileset src="dcevm-0.2-win.jar" includes="META-INF/MANIFEST.MF"/>
      <zipfileset src="dcevm-repackaged-full.jar" excludes="META-INF/MANIFEST.MF"/>
    </zip>
    <delete file="dcevm-repackaged-full.jar"/>
    <delete file="dcevm-repackaged.jar"/>
  </target>
</project>