Gradle daemon different context

I have Mac OS X Mountain Lion, Gradle 1.5 and the following ~/.gradle/ file


When I try to run gradle I get

AILURE: Build failed with an exception.
  * What went wrong:
The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. Context mismatch:
 Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home,daemonRegistryDir=/Users/Nikem/.gradle/daemon,pid=555,idleTimeout=null,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8]
Actual: DefaultDaemonContext[uid=0f3a0315-c1e6-44d6-962d-9a604d59a158,javaHome=/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre,daemonRegistryDir=/Users/Nikem/.gradle/daemon,pid=568,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8]

Can I do something with it?

This is almost certainly a bug.

Would you mind trying removing the ‘’ line from the ‘’ file and setting the ‘JAVA_HOME’ env var with the value? If that works, this will narrow down the problem we need to fix.

Without ‘’ it works like a charm from command line. JAVA_HOME env variable was always set.

In both cases, with and without, I have the same problem with Eclipse and IntelliJ when importing gradle project.

Is your ‘JAVA_HOME’ set to the same value?


echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home


For whatever reason I had symlink

/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre/lib/tools.jar pointing to /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/lib/tools.jar

It seems this confuses Gradle. After removing this symlink Gradle works without problems.

Nice catch.

It seems like this confused the canonicalization of the JAVA_HOME that we do to avoid using different daemons when they actually point to the same JDK/JRE.

Glad it’s working for you.