Gradle daemon different context


(Nikita Salnikov-Tarnovski) #1

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

org.gradle.daemon=true
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home

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?


(Luke Daley) #2

This is almost certainly a bug.

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


(Nikita Salnikov-Tarnovski) #3

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

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


(Luke Daley) #4

Is your ‘JAVA_HOME’ set to the same value?


(Nikita Salnikov-Tarnovski) #5

Yes,

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


(Nikita Salnikov-Tarnovski) #6

Ahha.

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.


(Luke Daley) #7

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.