Could not generate a proxy class for class org.gradle.invocation.DefaultGradle trying to run gradle

Hi, I’m pretty sure this is a silly problem, but after installing gradle on my production server, if I try to run gradle I got:

FAILURE: Build failed with an exception.
  * What went wrong:
Could not generate a proxy class for class org.gradle.invocation.DefaultGradle.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

And with --debug flag:

15:03:58.884 [ERROR] [system.err] * Exception is:
15:03:58.886 [ERROR] [system.err] java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/StackTraceUtils
15:03:58.886 [ERROR] [system.err]
at org.gradle.BuildExceptionReporter.write(BuildExceptionReporter.java:106)
15:03:58.887 [ERROR] [system.err]
at org.gradle.BuildExceptionReporter.execute(BuildExceptionReporter.java:73)
15:03:58.887 [ERROR] [system.err]
at org.gradle.BuildExceptionReporter.execute(BuildExceptionReporter.java:41)
15:03:58.888 [ERROR] [system.err]
at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:35)
15:03:58.889 [ERROR] [system.err]
at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:20)
15:03:58.889 [ERROR] [system.err]
at org.gradle.launcher.Main.doAction(Main.java:48)
15:03:58.890 [ERROR] [system.err]
at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:45)
15:03:58.891 [ERROR] [system.err]
at org.gradle.launcher.Main.main(Main.java:39)
15:03:58.891 [ERROR] [system.err]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:03:58.892 [ERROR] [system.err]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
15:03:58.892 [ERROR] [system.err]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
15:03:58.893 [ERROR] [system.err]
at java.lang.reflect.Method.invoke(Method.java:597)
15:03:58.894 [ERROR] [system.err]
at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
15:03:58.894 [ERROR] [system.err]
at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:32)
15:03:58.895 [ERROR] [system.err]
at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
15:03:58.896 [ERROR] [system.err] Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.StackTraceUtils
15:03:58.896 [ERROR] [system.err]
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
15:03:58.897 [ERROR] [system.err]
at java.security.AccessController.doPrivileged(Native Method)
15:03:58.898 [ERROR] [system.err]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
15:03:58.898 [ERROR] [system.err]
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
15:03:58.899 [ERROR] [system.err]
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
15:03:58.900 [ERROR] [system.err]
... 15 more

What could it be? Thanks Bye

Sounds like a corrupted Gradle installation or environment. For example, maybe you have some old libs lying around in the endorsed libs dir of the JVM installed on the server. Although the latter wouldn’t really explain this particular error.

Some other things to try:

  • Do a clean build * Delete the .gradle directory in the project directory

  • Delete (or temporarily rename) the .gradle directory in the user home

I knew it was a silly problem… * Delete the .gradle directory in the project directory made it work Thank you Peter!

I stumbled upon that very same issue today. In my situation, the error occurred because my build was using Gradle 1.4 and a plugin compiled with Gradle 1.9.

Changing the plugin build to use Gradle 1.4 fixed the issue (I couldn’t update the other build to 1.9 for a reason).