# Selected JDK is ignored for Maven build

XMLWordPrintable

#### Details

• Type: Bug
• Status: Closed
• Priority: Critical
• Resolution: Fixed
• Component/s:
• Labels:
None
• Environment:
Platform: PC, OS: Windows XP
• Similar Issues:

#### Description

I am running Hudson under Tomcat 5.5 with Java 1.5, building a single-module
Maven project. Since version 5.5 of Tomcat, it can be run with a JRE rather than
a JDK, as Tomcat comes bundled with the Java compiler from Eclipse.

Initially, I ran into problems compiling Java because, with the default
settings, it seemed to be using the JRE running Tomcat, which of course doesn't
have tools.jar. I then setup a JDK properly in Hudson, ensured that the project
was configured to use it, and tried again. It seemed to completely ignore this
setting and continued using the same JRE. I tried re-starting, but that had no
effect.

The only way I got this to work was to start Tomcat using a JDK - it appeared
that the JDK settings in Hudson were ignored.

Thanks, Alex.

#### Activity

Hide
Kohsuke Kawaguchi added a comment -

Thanks for the report. Fixed in 1.104.

Show
Kohsuke Kawaguchi added a comment - Thanks for the report. Fixed in 1.104.
Hide

Wow, that was quick! Thanks!

Show
alexmcmanus added a comment - Wow, that was quick! Thanks!
Hide

I tried this on the following snapshot version: Hudson ver. 1.104-SNAPSHOT
(private-04/21/2007 10:08-hudson)

The behaviour is now worse - it still ignores the Hudson JDK version, but it now
also ignores the JDK used to run Tomcat, so my workaround no longer works. It
appears to be picking up the latest installed JRE somehow, regardless of the
Hudson settings...

Show
alexmcmanus added a comment - I tried this on the following snapshot version: Hudson ver. 1.104-SNAPSHOT (private-04/21/2007 10:08-hudson) The behaviour is now worse - it still ignores the Hudson JDK version, but it now also ignores the JDK used to run Tomcat, so my workaround no longer works. It appears to be picking up the latest installed JRE somehow, regardless of the Hudson settings...
Hide
Kohsuke Kawaguchi added a comment -

I added another probe point in Hudson. So please first install another snapshot,
say, an hour from now. Then I'd like to ask you to try the following things:

1. when you launch Hudson, go to http://yourhost/script, and execute
"hudson.maven.MavenBuild.debug=true;". This activates the additional debug outputs.

2. start your build. In the console output you should see messages like:

Using env variables:

{EXECUTOR_NUMBER=0, JOB_NAME=org.jvnet.hudson.main:hudson-core, BUILD_ID=2007-04-21_18-15-25, JAVA_HOME=c:\development\versioned\j2sdk1.5.0_06, BUILD_TAG=hudson-org.jvnet.hudson.main:hudson-core-111, HUDSON_HOME=c:\kohsuke\My Projects\hudson\hudson\main\war\work, PATH=c:\development\versioned\j2sdk1.5.0_06\bin;..., BUILD_NUMBER=111}

That is the environment variable that Hudson is passing to the newly launched
Maven. Could you try this and see what you'll see?

3. If this is Windows, could you run Process Explorer and check the environment
variables that the Maven process is using? In particular, JAVA_HOME and PATH are
relevant.

Show
Kohsuke Kawaguchi added a comment - I added another probe point in Hudson. So please first install another snapshot, say, an hour from now. Then I'd like to ask you to try the following things: 1. when you launch Hudson, go to http://yourhost/script , and execute "hudson.maven.MavenBuild.debug=true;". This activates the additional debug outputs. 2. start your build. In the console output you should see messages like: Using env variables: {EXECUTOR_NUMBER=0, JOB_NAME=org.jvnet.hudson.main:hudson-core, BUILD_ID=2007-04-21_18-15-25, JAVA_HOME=c:\development\versioned\j2sdk1.5.0_06, BUILD_TAG=hudson-org.jvnet.hudson.main:hudson-core-111, HUDSON_HOME=c:\kohsuke\My Projects\hudson\hudson\main\war\work, PATH=c:\development\versioned\j2sdk1.5.0_06\bin;..., BUILD_NUMBER=111} That is the environment variable that Hudson is passing to the newly launched Maven. Could you try this and see what you'll see? 3. If this is Windows, could you run Process Explorer and check the environment variables that the Maven process is using? In particular, JAVA_HOME and PATH are relevant.
Hide

OK, here's my configuration, now using snapshot version 1.104-SNAPSHOT
(private-04/21/2007 06:11-hudson):

Tomcat is starting using C:\Program Files\Java\jre1.5.0_03.
The JDK in Hudson is set to C:\Program Files\Java\jdk1.5.0_03, and the project
is set to use this JDK.

From the (debugging) console output:

=======
started

Reporters=[hudson.maven.reporters.MavenArtifactArchiver@1908404,
hudson.maven.reporters.MavenFingerprinter@cb5de2,
hudson.maven.reporters.SurefireArchiver@60cf12,
hudson.maven.reporters.BuildInfoRecorder@1bac9d0]

Using env variables:

{JOB_NAME=uk.co.alexmcmanus:testtools, HUDSON_HOME=C:\.hudson, BUILD_NUMBER=26, BUILD_TAG=hudson-uk.co.alexmcmanus:testtools-26, JAVA_HOME=C:\Program Files\Java\jdk1.5.0_03, BUILD_ID=2007-04-22_18-10-06, PATH=C:\Program Files\Java\jdk1.5.0_03\bin, EXECUTOR_NUMBER=1}

\$ java -cp "C:\Program Files\Apache Software Foundation\Tomcat
5.5\webapps\hudson\WEB-INF\lib\maven-agent-1.104-SNAPSHOT.jar;C:\ProgramFiles\maven-2.0.4\core\boot\classworlds-1.1.jar"
hudson.maven.agent.Main C:\ProgramFiles\maven-2.0.4 "C:\Program Files\Apache
Software Foundation\Tomcat
5.5\webapps\hudson\WEB-INF\lib\remoting-1.104-SNAPSHOT.jar" "C:\Program
Files\Apache Software Foundation\Tomcat
5.5\webapps\hudson\WEB-INF\lib\maven-interceptor-1.104-SNAPSHOT.jar"

channel started

[INFO] Scanning for projects...
=======

So, according to that it seems to be choosing the correct JDK. However, if you
look further down in the console output, Maven reports that it is actually using
a different JDK (neither the one that I set, or the Tomcat JDK):

=======
[INFO] Compilation failure

Unable to locate the Javac Compiler in:

C:\Program Files\Java\jre1.5.0_11\..\lib\tools.jar
=======

Strange..! Ahh, that's interesting - checking the environment properties of the
Tomcat process, it has JAVA_HOME set to C:\Program Files\Java\jre1.5.0_11, which
at least explains where that came from. I don't know what magic is setting the
JAVA_HOME to that - there is no Tomcat configuration for it as far as I know,
and if I open a DOS console and echo %JAVA_HOME%, it comes up with
"C:\j2sdk1.4.2_04"..!

Cheers, Alex.

Show
alexmcmanus added a comment - OK, here's my configuration, now using snapshot version 1.104-SNAPSHOT (private-04/21/2007 06:11-hudson): Tomcat is starting using C:\Program Files\Java\jre1.5.0_03. The JDK in Hudson is set to C:\Program Files\Java\jdk1.5.0_03, and the project is set to use this JDK. From the (debugging) console output: ======= started Reporters=[hudson.maven.reporters.MavenArtifactArchiver@1908404, hudson.maven.reporters.MavenFingerprinter@cb5de2, hudson.maven.reporters.MavenJavadocArchiver@180ab18, hudson.maven.reporters.SurefireArchiver@60cf12, hudson.maven.reporters.BuildInfoRecorder@1bac9d0] Using env variables: {JOB_NAME=uk.co.alexmcmanus:testtools, HUDSON_HOME=C:\.hudson, BUILD_NUMBER=26, BUILD_TAG=hudson-uk.co.alexmcmanus:testtools-26, JAVA_HOME=C:\Program Files\Java\jdk1.5.0_03, BUILD_ID=2007-04-22_18-10-06, PATH=C:\Program Files\Java\jdk1.5.0_03\bin, EXECUTOR_NUMBER=1} \$ java -cp "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\hudson\WEB-INF\lib\maven-agent-1.104-SNAPSHOT.jar;C:\ProgramFiles\maven-2.0.4\core\boot\classworlds-1.1.jar" hudson.maven.agent.Main C:\ProgramFiles\maven-2.0.4 "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\hudson\WEB-INF\lib\remoting-1.104-SNAPSHOT.jar" "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\hudson\WEB-INF\lib\maven-interceptor-1.104-SNAPSHOT.jar" channel started [INFO] Scanning for projects... ======= So, according to that it seems to be choosing the correct JDK. However, if you look further down in the console output, Maven reports that it is actually using a different JDK (neither the one that I set, or the Tomcat JDK): ======= [INFO] Compilation failure Unable to locate the Javac Compiler in: C:\Program Files\Java\jre1.5.0_11\..\lib\tools.jar ======= Strange..! Ahh, that's interesting - checking the environment properties of the Tomcat process, it has JAVA_HOME set to C:\Program Files\Java\jre1.5.0_11, which at least explains where that came from. I don't know what magic is setting the JAVA_HOME to that - there is no Tomcat configuration for it as far as I know, and if I open a DOS console and echo %JAVA_HOME%, it comes up with "C:\j2sdk1.4.2_04"..! Cheers, Alex.
Hide
Kohsuke Kawaguchi added a comment -

This time it should be really really fixed — v1.105

Show
Kohsuke Kawaguchi added a comment - This time it should be really really fixed — v1.105
Hide

I can confirm this is now fixed in the latest snapshot.

Thanks very much!

Alex.

Show
alexmcmanus added a comment - I can confirm this is now fixed in the latest snapshot. Thanks very much! Alex.

#### People

Assignee:
Unassigned
Reporter:
alexmcmanus