Failed to connect to daemon in test code

JUnit test code throws the following error when attempting to connect to a daemon (newly spawned): https://gist.github.com/anonymous/5614197

I connect by specifying the version for Gradle (1.6) and the JDK home directory but nothing special.

I have extracted the interesting part from the stacktrace:

It won't be possible to reconnect to this daemon. Context mismatch:
 Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=C:\Program Files\Java\jdk1.6.0_29\jre,daemonRegistryDir=C:\Users\Kelemen Attila\.gradle\daemon,pid=3304,idleTimeout=null,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1250]
Actual: DefaultDaemonContext[uid=5c9b4a84-5679-4c30-a9a4-3eda317c8c9b,javaHome=C:\Program Files\Java\jdk1.6.0_29,daemonRegistryDir=C:\Users\Kelemen Attila\.gradle\daemon,pid=5792,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1250]

As you can see the difference is “uid=null” and “idleTimeout=null”.

EDIT: Just noticed that the real difference is “C:\Program Files\Java\jdk1.6.0_29\jre” and “C:\Program Files\Java\jdk1.6.0_29”. It is strange because the same code works inside the NetBeans Gradle plugin.

EDIT2: The difference in test code and real code is that for Java home (‘ModelBuilder.setJavaHome’) a JRE (within the JDK directory) is specified instead of JDK dir. I don’t know if it is something expected to happen for this case.

Is there any way that you can provide a reproducible sample that we can use?

I believe that if you set ModelBuilder.setJavaHome(“C:\Program Files\Java\jdk1.6.029\jre”), then it will reproduce, assuming that “C:\Program Files\Java\jdk1.6.029” is a directory of a JDK. I will try to create a simple script which may reproduces the problem.

Here is a simple Gradle build which reproduces the issue: https://gist.github.com/anonymous/5658997 Running ‘gradle jdkTask’ reproduces the issue (although the ‘jreHomeInJdk’ line has to be changed appropriately).

Do you get the same thing if you use the JDK root dir instead of the JRE child dir?

No, it works if I specify the JDK root dir.