# Gradle daemon different context

**URL:** <https://discuss.gradle.org/t/gradle-daemon-different-context/2146>\
**Category:** Old Forum Archive\
**Created:** [April 15, 2013, 7:18am UTC](https://discuss.gradle.org/t/gradle-daemon-different-context/2146 "2013-04-15T07:18:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikem](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/nikem/32/232_2.png) [@Nikem](https://discuss.gradle.org/u/Nikem)\
**Post date:** [April 15, 2013, 7:18am UTC](https://discuss.gradle.org/t/gradle-daemon-different-context/2146/1 "2013-04-15T07:18:00Z")

</div>

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

```gradle
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

```gradle
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?

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [April 15, 2013, 8:51am UTC](https://discuss.gradle.org/t/gradle-daemon-different-context/2146/2 "2013-04-15T08:51:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Nikem](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/nikem/32/232_2.png) [@Nikem](https://discuss.gradle.org/u/Nikem)\
**Post date:** [April 15, 2013, 9:09am UTC](https://discuss.gradle.org/t/gradle-daemon-different-context/2146/3 "2013-04-15T09:09:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [April 15, 2013, 9:10am UTC](https://discuss.gradle.org/t/gradle-daemon-different-context/2146/4 "2013-04-15T09:10:00Z")

</div>

Is your ‘JAVA\_HOME’ set to the same value?

---

<div class="post-metadata">

**Author:** ![Nikem](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/nikem/32/232_2.png) [@Nikem](https://discuss.gradle.org/u/Nikem)\
**Post date:** [April 15, 2013, 9:14am UTC](https://discuss.gradle.org/t/gradle-daemon-different-context/2146/5 "2013-04-15T09:14:00Z")

</div>

Yes,

echo $JAVA\_HOME /Library/Java/JavaVirtualMachines/jdk1.7.0\_17.jdk/Contents/Home

---

<div class="post-metadata">

**Author:** ![Nikem](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/nikem/32/232_2.png) [@Nikem](https://discuss.gradle.org/u/Nikem)\
**Post date:** [April 15, 2013, 2:06pm UTC](https://discuss.gradle.org/t/gradle-daemon-different-context/2146/6 "2013-04-15T14:06:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [April 15, 2013, 2:43pm UTC](https://discuss.gradle.org/t/gradle-daemon-different-context/2146/7 "2013-04-15T14:43:00Z")

</div>

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.
