GradleException: Could not load compiled classes for build file. Fails on all scripts, even after removing cache

I’ve recently been getting showstopping build errors on all tasks, all build scripts I try to run on my machine, due to this error.

I’ve tried to research this problem and see that people mention clearing the user profile .gradle dir as a fix, but it does not help me. The error does not change.

Gradle 1.11

Build time:

2014-02-11 11:34:39 UTC Build number: none Revision:



1.8.6 Ant:

Apache Ant™ version 1.9.2 compiled on July 8 2013 Ivy:

2.2.0 JVM:

1.7.0_51 (Oracle Corporation 24.51-b03) OS:

Windows 7 6.1 amd64

Here’s an example of the problem:

C:\temp\gradle\test>gradle tasks
  FAILURE: Build failed with an exception.
  * What went wrong:
A problem occurred configuring root project 'test'.
> Could not load compiled classes for build file 'C:\temp\gradle\test\build.gradle' from cache.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  Total time: 6.367 secs

and here’s a stacktrace:

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'test'.
        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(
        at org.gradle.api.internal.project.AbstractProject.evaluate(
        at org.gradle.api.internal.project.AbstractProject.evaluate(
        at org.gradle.configuration.DefaultBuildConfigurer.configure(
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(
        at org.gradle.launcher.Main.doAction(
        at org.gradle.launcher.Main.main(
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(
        at org.gradle.launcher.GradleMain.main(
Caused by: org.gradle.api.GradleException: Could not load compiled classes for build file 'C:\temp\gradle\test\build.gradle' from cache.
        at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.loadFromDir(
        at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler.compile(
        at org.gradle.groovy.scripts.internal.ShortCircuitEmptyScriptCompiler.compile(
        at org.gradle.groovy.scripts.internal.CachingScriptClassCompiler.compile(
        at org.gradle.groovy.scripts.DefaultScriptCompilerFactory$ScriptCompilerImpl.compile(
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(
        at org.gradle.configuration.project.BuildScriptProcessor.execute(
        at org.gradle.configuration.project.BuildScriptProcessor.execute(
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(
        ... 25 more
Caused by: java.lang.ClassNotFoundException: build_6fahaj53d4pdh2pq90o4lu9vl2
        at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.loadFromDir(
        ... 34 more
Caused by: C:\Users\r6pw2\.gradle\caches.11\scripts\build_6fahaj53d4pdh2pq90o4lu9vl2\ProjectScript\no_buildscript\classes\build
_6fahaj53d4pdh2pq90o4lu9vl2.class (Access is denied)
        ... 35 more

Any help would be greatly appreciated. I’m not sure why this stuff is now breaking as it used to work before, without any build.gradle, gradle runtime, or JVM changes. I’ve tried removing both the user profile .gradle and the project .gradle dirs, but the error remains.

Sounds like a file permission problem. Does the mentioned class file for which “access is denied” exist?

It does exist, yes. And my user has access to read/edit it.

In this directory, I see for example:


Volume in drive C is OSDisk

Volume Serial Number is 1C21-D205

Directory of C:\Users\r6pw2.gradle\caches\1.11\scripts\build_7jsb72rtc4k4m5e12ik1ap5qqa\ProjectScript\no_buildscript\classes

03/04/2014 11:20 AM

. 03/04/2014 11:20 AM

… 03/04/2014 11:18 AM

3,289 build_7jsb72rtc4k4m5e12ik1ap5qqa$_run_closure1.class 03/04/2014 11:18 AM

3,452 build_7jsb72rtc4k4m5e12ik1ap5qqa$_run_closure1_closure6.class 03/04/2014 11:18 AM

3,240 build_7jsb72rtc4k4m5e12ik1ap5qqa$_run_closure2.class 03/04/2014 11:18 AM

3,444 build_7jsb72rtc4k4m5e12ik1ap5qqa$_run_closure3.class 03/04/2014 11:18 AM

3,288 build_7jsb72rtc4k4m5e12ik1ap5qqa$_run_closure4.class 03/04/2014 11:18 AM

3,293 build_7jsb72rtc4k4m5e12ik1ap5qqa$_run_closure5.class 03/04/2014 11:18 AM

3,333 build_7jsb72rtc4k4m5e12ik1ap5qqa$_run_closure5_closure7.class 03/04/2014 11:18 AM

3,258 build_7jsb72rtc4k4m5e12ik1ap5qqa$_run_closure5_closure7_closure8.class 03/04/2014 11:18 AM

10,141 build_7jsb72rtc4k4m5e12ik1ap5qqa.class

9 File(s)

36,738 bytes

2 Dir(s) 257,536,319,488 bytes free

when the exception contains: Caused by: C:\Users\r6pw2.gradle\caches\1.11\scripts\build_7jsb72rtc4k4m5e12ik1ap5qqa\ProjectScript\no_buildscript\classes\build _7jsb72rtc4k4m5e12ik1ap5qqa.class (Access is denied)

Hard to say from here, but “access is denied” sounds like a file permission problem to me.

Ok, I agree, that is what it sounds like.

Thanks for the insight; I’ll keep digging.

I’ve tried just about everything I can think of and haven’t gotten anywhere. I’ve tried other Gradle versions (1.5), other JVM (1.6), still get this same error.

Such a strange problem; last time I tried this everything worked fine. If anyone has any more diagnostic suggestions, I’d greatly appreciate it!

I’m starting to wonder if some security software on my machine is interfering, but have no way I can think of to verify this.

I’m happy to report that the problem was indeed due to security software running on my machine. Apparently it was blocking the JVM from “running” random files it didn’t know about.