AA
asked on
Jenkins Windows slave: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK
Hi everyone,
I'm encountering a weird issue from Windows slave in Jenkins, I tried many solutions provided in Stackoverflow, but no luck. So I re-post my question here to looking for your support.
I just setup a new jenkins slave which is running Windows server 2012. I already installed jdk-8u221-windows-x64 and set Java_home, Path like below
However,build job running in this slave always complain that:
Here is a slave node configuration:
In a Job build configuration, I selected (System) in JDK option. If I choose JDK 8 update 221, this build job run successfully, but I want to use a (System) JDK which will get from environment variable in this node, so I can switch to another slave node without changing the JDK option.
However, when I remote to this server, and open command prompt, cd to workspace folder of this project, let say: C:\jenkins_slave\workspace \project01 \, then type the command: mvn clean install, it run without complain about jdk or jre as run from Jenkins. That's very surprise.
Any idea of what might be causing this? If you need more info, please let me know.
Thanks.
I'm encountering a weird issue from Windows slave in Jenkins, I tried many solutions provided in Stackoverflow, but no luck. So I re-post my question here to looking for your support.
I just setup a new jenkins slave which is running Windows server 2012. I already installed jdk-8u221-windows-x64 and set Java_home, Path like below
C:\Users\Administrator>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_221\
C:\Users\Administrator>echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\
Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\
Program Files\Amazon\cfn-bootstrap\;C:\Program Files\Git\cmd;C:\Program Files\Ja
va\jdk1.8.0_221\\bin;C:\maven\bin;C:\maven\bin
However,build job running in this slave always complain that:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK
Here is a slave node configuration:
In a Job build configuration, I selected (System) in JDK option. If I choose JDK 8 update 221, this build job run successfully, but I want to use a (System) JDK which will get from environment variable in this node, so I can switch to another slave node without changing the JDK option.
However, when I remote to this server, and open command prompt, cd to workspace folder of this project, let say: C:\jenkins_slave\workspace
Any idea of what might be causing this? If you need more info, please let me know.
Thanks.
ASKER
Hi CEHJ,
Java.exe and javac.exe also existing in bin directory, thus can I run a local build in this node for testing.
The issue just happen if I build from Jenkins.
Thanks.
Well, as you can see from your echo %PATH% command, the jdk is NOT in it.The jdk is alreary in Path variable, please see the last line of the echo output.
Java.exe and javac.exe also existing in bin directory, thus can I run a local build in this node for testing.
The issue just happen if I build from Jenkins.
Thanks.
Oh sorry. But that's probably not the one that will be used. The path is resolved in order and the one including 'javapath' (likely a JRE) is probably the one that will be used. Try what i suggested
ASKER
Hi CEHJ,
I just try to remove this javapath(C:\Program Files (x86)\Common Files\Oracle\Java\javapath ), restart this node, and re-build, but this issue still occur.
I just try to remove this javapath(C:\Program Files (x86)\Common Files\Oracle\Java\javapath
Can you show me the output of echo %PATH% with a new cmd window now?
ASKER
Yes, please see
C:\Users\Administrator>echo %path%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\Wind
owsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\Program Files\Git\
cmd;C:\Program Files\Java\jdk1.8.0_221\bin;C:\maven\bin
C:\Users\Administrator>
OK, now try starting from that same command line
ASKER
What do you want to start from this command line?
well - whatever it is you're running
ASKER
As I mentioned in the question. I have no problem if run maven build in this local node.
The point is that whatever you're running must be run with that PATH
ASKER
Yes, this is what I don't understand why Jenkins not run with that PATH. Even though the Jenkins configuration seen correct.
Perhaps there's something internally configured and it's ignoring your environment. That would be pretty dumb of it but might explain it
There's several ways this could be failing to set the environment correctly - so I'd suggest gathering more information.
Try setting up a very simple Jenkins job, whose entire function is to print out a few environment variables.
This page: https://www.theserverside.com/tutorial/Jenkins-environment-variables-list-for-shell-script-build-jobs
helps explain how.
All you need is a shell script which echos $Path and maybe $JAVA_HOME.
(Note that Jenkins seems to use $Path as a generic reference for the windows env variable %PATH% - so you may want to echo $Path or %PATH%)
Then you can run this script and see exactly what Jenkins is setting the Path to.
Is it:
a) Unchanged?
b) Includes C:\Program Files\Java\jdk1.8.0_221\ but perhaps isn't handling the spaces correctly in "Program Files"?
c) Something else?
Can you try that and post what you get? That should help narrow down exactly where the problem is.
Doug
Try setting up a very simple Jenkins job, whose entire function is to print out a few environment variables.
This page: https://www.theserverside.com/tutorial/Jenkins-environment-variables-list-for-shell-script-build-jobs
helps explain how.
All you need is a shell script which echos $Path and maybe $JAVA_HOME.
(Note that Jenkins seems to use $Path as a generic reference for the windows env variable %PATH% - so you may want to echo $Path or %PATH%)
Then you can run this script and see exactly what Jenkins is setting the Path to.
Is it:
a) Unchanged?
b) Includes C:\Program Files\Java\jdk1.8.0_221\ but perhaps isn't handling the spaces correctly in "Program Files"?
c) Something else?
Can you try that and post what you get? That should help narrow down exactly where the problem is.
Doug
ASKER
That's all in order. To back up a bit: your problem is that things fall over when you choose 'System'?
ASKER
That's all in order. To back up a bit: your problem is that things fall over when you choose 'System'?Yes. Beside this node, I also have some windows slave nodes, they are working well with the same configuration.
So on the node where you choose System, perhaps the environment has not been set up properly for all the components of the build...
ASKER
Actually, i did not find out what is wrong in node configuration.
Well you'd need to run that previous script on that particular node
ASKER
I just run the previous script in two node. Here is a output in working node
This is an output in failed node(This node have issue with JDK or JRE when bulid from Jenkins).
I already clone the working node to replace a failed node. But this issue still occur, so I thinks the problem is not from a node, but from a Jenkins configuration.
Thanks.
This is an output in failed node(This node have issue with JDK or JRE when bulid from Jenkins).
I already clone the working node to replace a failed node. But this issue still occur, so I thinks the problem is not from a node, but from a Jenkins configuration.
Thanks.
I know we're rather clutching at straws here but one of the things which immediately struck me in the path you posted on the machine that is not working is this rather odd entry for Amazon:
Note that there is a space in your output before "cmd" in the path which is failing.
If you look at the path that is not failing, there is no space before "cmd".
Since the Java path comes after that, I wonder if the path is somehow getting messed up at that point?
However, the fact that when you just run "java --version" it's the correct output suggests maybe not? But just seems odd in the output.
... :/c/Program Files/Amazon/cfn-boostrap:/ cmd:/c/Program Files/Java/jdk.1.8.0_221/bin
Note that there is a space in your output before "cmd" in the path which is failing.
If you look at the path that is not failing, there is no space before "cmd".
Since the Java path comes after that, I wonder if the path is somehow getting messed up at that point?
However, the fact that when you just run "java --version" it's the correct output suggests maybe not? But just seems odd in the output.
ASKER
I just remoe the space before "cmd", but this issue still occur.
[Test Shell on Win] $ C:\Program Files\Git\bin\bash.exe C:\Windows\TEMP\jenkins735334340111766039.sh
C:\Program Files\Java\jdk1.8.0_221
PATH:
/mingw64/bin:/usr/bin:/c/Windows/system32/config/systemprofile/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/Amazon/cfn-bootstrap:/cmd:/c/Program Files/Java/jdk1.8.0_221/bin:/c/maven/bin:/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/c/ProgramData/Oracle/Java/javapath
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)
Maven home: C:\maven
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_221\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2012 r2", version: "6.3", arch: "amd64", family: "windows"
git version 2.23.0.windows.1
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
javac 1.8.0_221
[Office365connector] No webhooks to notify
Finished: SUCCESS
This is also suspect
btw, please try to post this output as code text, not an image as it's difficult to work with
c:/Windows/System32/Wind owsPowerShell
btw, please try to post this output as code text, not an image as it's difficult to work with
ASKER
Hi CEHJ
I correct it, here is a latest output
I correct it, here is a latest output
[Test Shell on Win] $ C:\Program Files\Git\bin\bash.exe C:\Windows\TEMP\jenkins735334340111766039.sh
C:\Program Files\Java\jdk1.8.0_221
PATH:
/mingw64/bin:/usr/bin:/c/Windows/system32/config/systemprofile/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/Amazon/cfn-bootstrap:/cmd:/c/Program Files/Java/jdk1.8.0_221/bin:/c/maven/bin:/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/c/ProgramData/Oracle/Java/javapath
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)
Maven home: C:\maven
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_221\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2012 r2", version: "6.3", arch: "amd64", family: "windows"
git version 2.23.0.windows.1
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
javac 1.8.0_221
[Office365connector] No webhooks to notify
Finished: SUCCESS
The PATH output in this console is not in order as the output in command prompt.C:\Users\Administrator>echo %path%
C:\Program Files\Java\jdk1.8.0_221\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\Program Files\Git\cmd;C:\maven\bin
Currently, I disable Environment variables in Jenkins node properties.
That's slightly odd output. Are you running a script to produce that output and if so, can you post it below?
ASKER
Hi CEHj
The output which I post above is the latest output.
The output which I post above is the latest output.
No - i'm looking for the script, not the output of the script
ASKER
Ya, here is a script
#!C:\Program Files\Git\bin\bash.exe
echo $JAVA_HOME
echo $PATH
mvn -v
git --version
java -version
javac -version
OK, i thought that's what you'd post. It's a little odd that the word "PATH" is appearing at all. Can we change that please to the following and then post the output
#!C:\Program Files\Git\bin\bash.exe
echo -e "JAVA_HOME=\n"
echo $JAVA_HOME
echo -e "***********************\n"
echo -e "PATH=\n"
echo $PATH
echo -e "***********************\n"
echo -e "Maven version=\n"
mvn -v
echo -e "***********************\n"
echo -e "Git version=\n"
git --version
echo -e "***********************\n"
echo -e "Java version=\n"
java -version
echo -e "***********************\n"
echo -e "javac version=\n"
javac -version
echo -e "***********************\n"
ASKER
Please see output after using your script
[Office365connector] No webhooks to notify
[EnvInject] - Loading node environment variables.
Building remotely on aws-fra-everest in workspace C:\jenkins_slave\workspace\Test Shell on Win
[Test Shell on Win] $ C:\Program Files\Git\bin\bash.exe C:\Windows\TEMP\jenkins1381380697575 418948.sh
JAVA_HOME=
C:\Program Files\Java\jdk1.8.0_221
***********************
PATH=
/mingw64/bin:/usr/bin:/c/Windows/sys tem32/conf ig/systemp rofile/bin :/c/Window s/system32 :/c/Window s:/c/Windo ws/System3 2/Wbem:/c/ Windows/Sy stem32/Win dowsPowerS hell/v1.0: /c/Program Files/Amazon/cfn-bootstrap :/cmd:/c/P rogram Files/Java/jdk1.8.0_221/bi n:/c/maven /bin:/c/Pr ogram Files (x86)/Common Files/Oracle/Java/javapath :/c/Progra mData/Orac le/Java/ja vapath
***********************
Maven version=
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6 af555; 2019-04-04T19:00:29Z)
Maven home: C:\maven
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_221\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2012 r2", version: "6.3", arch: "amd64", family: "windows"
***********************
Git version=
git version 2.23.0.windows.1
***********************
Java version=
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
***********************
javac version=
***********************
javac 1.8.0_221
[Office365connector] No webhooks to notify
Finished: SUCCESS
You were quick - too quick to get my corrected version (above) ;)
I can't see anything wrong there - perhaps Doug can. You might remove anything with "javapath" in it as that's not required
I can't see anything wrong there - perhaps Doug can. You might remove anything with "javapath" in it as that's not required
A slight problem for me is that i don't know Jenkins. How are you triggering what is failing - through a web page?
You should also be able to get an idea of what is failing and why from the Jenkins log:
https://wiki.jenkins.io/display/JENKINS/Logging
You should also be able to get an idea of what is failing and why from the Jenkins log:
https://wiki.jenkins.io/display/JENKINS/Logging
Thorny problem.
The next step I'd suggest following is digging deeper into maven. After all, the root error that we're getting is from mvn - when it presumably tries to check for the "javac.exe" file in a specific location. So maybe we need to try to figure out which location it's looking in?
On Windows, maven's install bin folder should contain a "mvn.cmd" file.
I would suggest:
a) Make a copy of this file (you'll want to reset it back to this when we're done editing)
b) Edit the mvn.cmd and locate the point where it actually calls Java. For my install this looks like:
I would add some echo statements directly in here - to see if this shakes anything loose:
Now when you run mvn from the command line, you'll see the Java instance that is being launched - the full path. Make sure that looks correct.
Then try it from Jenkins - maybe you'll get different output when mvn is launched by Jenkins?
Ultimately we need to find:
where is mvn looking for the JDK?
is there a javac.exe compiler in that location?
Doug
The next step I'd suggest following is digging deeper into maven. After all, the root error that we're getting is from mvn - when it presumably tries to check for the "javac.exe" file in a specific location. So maybe we need to try to figure out which location it's looking in?
On Windows, maven's install bin folder should contain a "mvn.cmd" file.
I would suggest:
a) Make a copy of this file (you'll want to reset it back to this when we're done editing)
b) Edit the mvn.cmd and locate the point where it actually calls Java. For my install this looks like:
for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
"%JAVACMD%" ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %CLASSWORLDS_JAR% ^
"-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" ^
"-Dmaven.home=%MAVEN_HOME%" ^
"-Dlibrary.jansi.path=%MAVEN_HOME%\lib\jansi-native" ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end
I would add some echo statements directly in here - to see if this shakes anything loose:
for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i"
set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
echo "%JAVACMD%"
echo "%JMAVN_OPTS%"
echo "%JAVACMD%" ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %CLASSWORLDS_JAR% ^
"-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" ^
"-Dmaven.home=%MAVEN_HOME%" ^
"-Dlibrary.jansi.path=%MAVEN_HOME%\lib\jansi-native" ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
"%JAVACMD%" ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %CLASSWORLDS_JAR% ^
"-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" ^
"-Dmaven.home=%MAVEN_HOME%" ^
"-Dlibrary.jansi.path=%MAVEN_HOME%\lib\jansi-native" ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end
Now when you run mvn from the command line, you'll see the Java instance that is being launched - the full path. Make sure that looks correct.
Then try it from Jenkins - maybe you'll get different output when mvn is launched by Jenkins?
Ultimately we need to find:
where is mvn looking for the JDK?
is there a javac.exe compiler in that location?
Doug
After all, the root error that we're getting is from mvnI obviously missed that ;) Where did you get that from?
ASKER
Hi Doug,
I tried to edit the file mvn.cmd, then run mvn in command line, I got the output:
This is a log from Jenkins
I tried to edit the file mvn.cmd, then run mvn in command line, I got the output:
C:\jenkins_slave\workspace\ELIAS_Frequent_ICT\currenta-elias>mvn clean install -
Pjacoco-offline
"Defined manual by DungTT"
"C:\Program Files\Java\jdk1.8.0_221\bin\java.exe"
""
"C:\Program Files\Java\jdk1.8.0_221\bin\java.exe" -classpath "C:\mave
n\bin\..\boot\plexus-classworlds-2.6.0.jar" "-Dclassworlds.conf=C:\maven\bin\.
.\bin\m2.conf" "-Dmaven.home=C:\maven\bin\.." "-Dlibrary.jansi.path=C:\maven
\bin\..\lib\jansi-native" "-Dmaven.multiModuleProjectDirectory=C:\jenkins_slav
e\workspace\ELIAS_Frequent_ICT\currenta-elias" org.codehaus.plexus.classworlds
.launcher.Launcher clean install -Pjacoco-offline
This is a log from Jenkins
11:43:00 [ELIAS_Frequent_ICT] $ cmd.exe /C "mvn -f currenta-portal/Portal/pom.xml install && exit %%ERRORLEVEL%%"
11:43:00 "Defined manual by DungTT"
11:43:00 "C:\Program Files\Java\jdk1.8.0_221\bin\java.exe"
11:43:00 ""
11:43:00 "C:\Program Files\Java\jdk1.8.0_221\bin\java.exe" -classpath "C:\maven\bin\..\boot\plexus-classworlds-2.6.0.jar" "-Dclassworlds.conf=C:\maven\bin\..\bin\m2.conf" "-Dmaven.home=C:\maven\bin\.." "-Dlibrary.jansi.path=C:\maven\bin\..\lib\jansi-native" "-Dmaven.multiModuleProjectDirectory=C:\jenkins_slave\workspace\ELIAS_Frequent_ICT" org.codehaus.plexus.classworlds.launcher.Launcher -f currenta-portal/Portal/pom.xml install
11:43:00 Parsing POMs
11:43:01 Established TCP socket on 60229
11:43:01 maven35-agent.jar already up to date
11:43:01 maven35-interceptor.jar already up to date
11:43:01 maven3-interceptor-commons.jar already up to date
11:43:01 [currenta-elias] $ java -cp C:\jenkins_slave\maven35-agent.jar;C:\maven\boot\plexus-classworlds-2.6.0.jar;C:\maven/conf/logging jenkins.maven3.agent.Maven35Main C:\maven C:\jenkins_slave\slave.jar C:\jenkins_slave\maven35-interceptor.jar C:\jenkins_slave\maven3-interceptor-commons.jar 60229
What does the Jenkins log say?
ASKER
Sorry I just found the log from Jenkins is similar to command prompt. See my updated post above.
But that log doesn't show any error. If the build fails, make sure you check the log afterwards
ASKER
The log below is just mvn output. The job build log still the same
1:58:02 [INFO] Compiling sources in [src, src_hd, src_rd, src_ws, src_wsproc, src_dataClasses] to output directory 'classes'
11:58:05 [INFO] + [compiled 43057 lines in 3230 ms: 13330.3 lines/s]
11:58:05 [INFO] + [180 .class files generated]
11:58:05 [INFO]
11:58:05 [INFO] --- jacoco-maven-plugin:0.8.1:instrument (default-instrument) @ bus ---
11:58:06 [INFO]
11:58:06 [INFO] --- maven-compiler-plugin:3.5.1:testCompile (process-test-meta-model) @ bus ---
11:58:06 [INFO] Changes detected - recompiling the module!
11:58:06 [INFO] Compiling 4 source files to C:\jenkins_slave\workspace\ELIAS_Frequent_ICT\currenta-elias\elias_bus\classes
11:58:06 [INFO] -------------------------------------------------------------
11:58:06 [ERROR] COMPILATION ERROR :
11:58:06 [INFO] -------------------------------------------------------------
11:58:06 [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
11:58:06 [INFO] 1 error
11:58:06 [INFO] -------------------------------------------------------------
11:58:06 [Office365connector] No webhooks to notify
11:58:07 [INFO] ------------------------------------------------------------------------
11:58:07 [INFO] Reactor Summary for elias 1.3.0-SNAPSHOT:
11:58:07 [INFO]
11:58:07 [INFO] elias .............................................. SUCCESS [ 1.010 s]
11:58:07 [INFO] bus ................................................ FAILURE [ 20.177 s]
11:58:07 [INFO] base ............................................... SKIPPED
11:58:07 [INFO] mdmgmt ............................................. SKIPPED
11:58:07 [INFO] mdmgmt-admin ....................................... SKIPPED
11:58:07 [INFO] wastemgmt .......................................... SKIPPED
11:58:07 [INFO] ------------------------------------------------------------------------
11:58:07 [INFO] BUILD FAILURE
11:58:07 [INFO] ------------------------------------------------------------------------
11:58:07 [INFO] Total time: 23.030 s
11:58:07 [INFO] Finished at: 2019-09-18T09:58:04Z
11:58:07 [INFO] ------------------------------------------------------------------------
11:58:07 Waiting for Jenkins to finish collecting data
11:58:07 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:testCompile (process-test-meta-model) on project bus: Compilation failure
11:58:07 [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
11:58:07 [ERROR] -> [Help 1]
11:58:07 [ERROR]
11:58:07 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
11:58:07 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
11:58:07 [ERROR]
11:58:07 [ERROR] For more information about the errors and possible solutions, please read the following articles:
11:58:07 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
11:58:07 [ERROR]
11:58:07 [ERROR] After correcting the problems, you can resume the build with the command
11:58:07 [ERROR] mvn <goals> -rf :bus
Right. As Doug says, it's likely there's a environment/config conflict. See if you can trigger it in debug mode and you might find the log shows where the compiler is (or isn't) being read from
Well it's good to see that mvn is being launched with
"C:\Program Files\Java\jdk1.8.0_221\bi n\java.exe "
which means Jenkins seems to be setting the Path correctly.
I'm starting to suspect the problem is more with Maven than with Jenkins, per se.
One really dumb question - but can be just check that
"C:\Program Files\Java\jdk1.8.0_221\bi n\javac.ex e" <-- note: javac
exists on this machine?
I'm sure it does, but it would be classic if that file is somehow not present.
This page:
http://roufid.com/no-compiler-is-provided-in-this-environment/
suggests that the pom.xml file can be edited to specify a specific compiler.
Can you post the relevant section of your pom? Just to make sure that nothing odd is in there?
I also went so far as to download the maven source code and the compiler-plugin source code - to try to find exactly where that error message comes from "No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?" but alas I couldn't find it. Maven is plugins on plugins so it's out there somewhere but I didn't locate it.
I wanted to see how this test actually works. Presumably it's checking for "javac.exe" but does it look in $JAVA_HOME, on the $Path, somewhere else?
If we could determine precisely what causes this error, we could work back to which setting is incorrect.
"C:\Program Files\Java\jdk1.8.0_221\bi
which means Jenkins seems to be setting the Path correctly.
I'm starting to suspect the problem is more with Maven than with Jenkins, per se.
One really dumb question - but can be just check that
"C:\Program Files\Java\jdk1.8.0_221\bi
exists on this machine?
I'm sure it does, but it would be classic if that file is somehow not present.
This page:
http://roufid.com/no-compiler-is-provided-in-this-environment/
suggests that the pom.xml file can be edited to specify a specific compiler.
Can you post the relevant section of your pom? Just to make sure that nothing odd is in there?
I also went so far as to download the maven source code and the compiler-plugin source code - to try to find exactly where that error message comes from "No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?" but alas I couldn't find it. Maven is plugins on plugins so it's out there somewhere but I didn't locate it.
I wanted to see how this test actually works. Presumably it's checking for "javac.exe" but does it look in $JAVA_HOME, on the $Path, somewhere else?
If we could determine precisely what causes this error, we could work back to which setting is incorrect.
ASKER
Hi Doug
"C:\Program Files\Java\jdk1.8.0_221\biYes, it's existing.n\javac.ex e" <-- note: javac
exists on this machine?
Can you post the relevant section of your pom? Just to make sure that nothing odd is in there?In the pom file I did not specific jdk. I just created a new build job with the example repository https://github.com/javaparser/javaparser-maven-sample, and got the same error.
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
No credentials specified
Cloning the remote Git repository
Cloning repository https://github.com/javaparser/javaparser-maven-sample.git
> C:\Program Files\Git\cmd\git.exe init C:\jenkins_slave\workspace\maven-example # timeout=10
Fetching upstream changes from https://github.com/javaparser/javaparser-maven-sample.git
> C:\Program Files\Git\cmd\git.exe --version # timeout=10
> C:\Program Files\Git\cmd\git.exe fetch --tags --force --progress https://github.com/javaparser/javaparser-maven-sample.git +refs/heads/*:refs/remotes/origin/*
> C:\Program Files\Git\cmd\git.exe config remote.origin.url https://github.com/javaparser/javaparser-maven-sample.git # timeout=10
> C:\Program Files\Git\cmd\git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> C:\Program Files\Git\cmd\git.exe config remote.origin.url https://github.com/javaparser/javaparser-maven-sample.git # timeout=10
Fetching upstream changes from https://github.com/javaparser/javaparser-maven-sample.git
> C:\Program Files\Git\cmd\git.exe fetch --tags --force --progress https://github.com/javaparser/javaparser-maven-sample.git +refs/heads/*:refs/remotes/origin/*
> C:\Program Files\Git\cmd\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> C:\Program Files\Git\cmd\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 646cebbe630ab346277b39680c2db6b367a06b00 (refs/remotes/origin/master)
> C:\Program Files\Git\cmd\git.exe config core.sparsecheckout # timeout=10
> C:\Program Files\Git\cmd\git.exe checkout -f 646cebbe630ab346277b39680c2db6b367a06b00
Commit message: "Make the jar executable"
> C:\Program Files\Git\cmd\git.exe rev-list --no-walk 646cebbe630ab346277b39680c2db6b367a06b00 # timeout=10
Parsing POMs
Established TCP socket on 61454
maven35-agent.jar already up to date
maven35-interceptor.jar already up to date
maven3-interceptor-commons.jar already up to date
[maven-example] $ java -cp C:\jenkins_slave\maven35-agent.jar;C:\maven\boot\plexus-classworlds-2.6.0.jar;C:\maven/conf/logging jenkins.maven3.agent.Maven35Main C:\maven C:\jenkins_slave\slave.jar C:\jenkins_slave\maven35-interceptor.jar C:\jenkins_slave\maven3-interceptor-commons.jar 61454
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\jenkins_slave\workspace\maven-example\pom.xml clean install
[INFO] Scanning for projects...
[HUDSON] Collecting dependencies info
[Office365connector] No webhooks to notify
[INFO]
[INFO] ------------< com.yourorganization:javaparser-maven-sample >------------
[INFO] Building javaparser-maven-sample 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ javaparser-maven-sample ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javaparser-maven-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javaparser-maven-sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\jenkins_slave\workspace\maven-example\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class org.jfrog.hudson.maven2.MavenDependenciesRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[Office365connector] No webhooks to notify
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.041 s
[INFO] Finished at: 2019-09-19T02:44:49Z
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project javaparser-maven-sample: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[JENKINS] Archiving C:\jenkins_slave\workspace\maven-example\pom.xml to com.yourorganization/javaparser-maven-sample/1.0-SNAPSHOT/javaparser-maven-sample-1.0-SNAPSHOT.pom
channel stopped
[Office365connector] No webhooks to notify
Finished: FAILURE
so I'm not suspect the problem from pom file. :(
OK fair enough - that's a good test.
Plus it took me back to look at the documentation for Maven a bit more closely and turns out there's this important line here:
https://maven.apache.org/plugins/maven-compiler-plugin/
which means we're not actually trying to run "javac.exe" on this machine at all. We're trying to load an internal Java compiler class - i.e. a JAR file that is loaded as part of the full JDK.
Doesn't particularly explain what's wrong, but does indicate we (or at least I) have been looking up the wrong tree.
This also lead to finally finding where this error message is coming from. The error is from within this github project:
https://github.com/sonatype/plexus-compiler
and specifically this file JavaxToolsCompiler.java here which contains:
Digging deeper it looks like getJavaCompiler() basically just calls:
which in turn calls:
So I think the real question is - why does ToolProvider.getSystemJava Compiler() return null on this machine when run this way?
That's not necessarily a better question but it does seem like we're at least closing in on the root problem.
Plus it took me back to look at the documentation for Maven a bit more closely and turns out there's this important line here:
https://maven.apache.org/plugins/maven-compiler-plugin/
Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6) and is used to compile Java sources. If you want to force the plugin using javac, you must configure the plugin option forceJavacCompilerUse.
which means we're not actually trying to run "javac.exe" on this machine at all. We're trying to load an internal Java compiler class - i.e. a JAR file that is loaded as part of the full JDK.
Doesn't particularly explain what's wrong, but does indicate we (or at least I) have been looking up the wrong tree.
This also lead to finally finding where this error message is coming from. The error is from within this github project:
https://github.com/sonatype/plexus-compiler
and specifically this file JavaxToolsCompiler.java here which contains:
JavaCompiler compiler = getJavaCompiler( config );
try
{
if ( compiler == null )
{
CompilerMessage message = new CompilerMessage( "No compiler is provided in this environment. "
+ "Perhaps you are running on a JRE rather than a JDK?",
CompilerMessage.Kind.ERROR );
Digging deeper it looks like getJavaCompiler() basically just calls:
ToolProvider.getSystemJavaCompiler() ; // Part of the JDK
which in turn calls:
private static final String defaultJavaCompilerName
= "com.sun.tools.javac.api.JavacTool";
/**
* Gets the Java™ programming language compiler provided
* with this platform.
* @return the compiler provided with this platform or
* {@code null} if no compiler is provided
*/
public static JavaCompiler getSystemJavaCompiler() {
return instance().getSystemTool(JavaCompiler.class, defaultJavaCompilerName);
}
So I think the real question is - why does ToolProvider.getSystemJava
That's not necessarily a better question but it does seem like we're at least closing in on the root problem.
Also this does suggest something new to try - which is setting this flag:
forceJavacCompilerUse
as documented in https://maven.apache.org/plugins/maven-compiler-plugin/
If that flag is set, then that should make javac be used instead of the built in compiler task and that might work.
forceJavacCompilerUse
as documented in https://maven.apache.org/plugins/maven-compiler-plugin/
If that flag is set, then that should make javac be used instead of the built in compiler task and that might work.
ASKER
Do you mean I will add this to pom file?
forceJavacCompilerUse
"forceJavacCompilerUse
Do you mean I will add this to pom file?"
Yes that's right. See if switching to forcing to use Javac helps to solve this problem.
Do you mean I will add this to pom file?"
Yes that's right. See if switching to forcing to use Javac helps to solve this problem.
ASKER
I just add this to pom file, but seen like the build job still using JRE
Thanks.
pom.xml
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javaparser-maven-sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\jenkins_slave\workspace\maven-example\target\classes
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class org.jfrog.hudson.maven2.MavenDependenciesRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[Office365connector] No webhooks to notify
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.085 s
[INFO] Finished at: 2019-09-20T06:50:37Z
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project javaparser-maven-sample: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_221\..\lib\tools.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[JENKINS] Archiving C:\jenkins_slave\workspace\maven-example\pom.xml to com.yourorganization/javaparser-maven-sample/1.0-SNAPSHOT/javaparser-maven-sample-1.0-SNAPSHOT.pom
channel stopped
[Office365connector] No webhooks to notify
Finished: FAILURE
You can see a pom file in attachment.Thanks.
pom.xml
Try the following in there
<forceJavacCompilerUse>${maven.compiler.forceJavacCompilerUse}</forceJavacCompilerUse>
<fork>true</fork>
<executable>${java.home}/bin/javac</executable>
NB - i made a correction above
ASKER
Hi CEHJ,
I just changed as your suggestion. But still got the same issue above.
I just changed as your suggestion. But still got the same issue above.
[INFO] Finished at: 2019-09-20T09:24:34Z
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project javaparser-maven-sample: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_221\..\lib\tools.jar -> [Help 1]
Are you sure you're dealing with the right pom? If you are it's certainly ignoring what you're telling it to do since it's (probably) using the compiler from tools.jar (which in this case shouldn't be a problem should it?)
ASKER
Yes, I'm using a correct pom file.
But it still using a JRE as you can see
But it still using a JRE as you can see
I just confuse that changing a pom file, may not help to figure out an issue. Because this example project can build success in another windows slave, also build local.
tools.jar not found: C:\Program Files\Java\jre1.8.0_221\..\lib\tools .jar
But it still using a JRE as you can seeYes. As i say, it's ignoring the pom
If you're having problems with the pom the docs also say you can add:
-Dmaven.compiler.forceJava cCompilerU se=true
to the command line for mvn and see if that works.
There's clearly something very odd about the way the compiler is being run by Maven when launched as a slave by Jenkins. So we're trying to see if using a different compiler (javac) solves the problem. That's why we're suggesting messing around with this.
-Dmaven.compiler.forceJava
to the command line for mvn and see if that works.
There's clearly something very odd about the way the compiler is being run by Maven when launched as a slave by Jenkins. So we're trying to see if using a different compiler (javac) solves the problem. That's why we're suggesting messing around with this.
One thing i often do in this kind of configuration case is to check the last access timestamp of the config file. If it's not right it will confirm it's not being used. You could then search for other files where the timestamp is right
ASKER
I just add the -Dmaven.compiler.forceJava cCompilerU se=true to "Goals and options" in Jenkins build job and in the command line for mvn. The output is difference.
Here is output from Jenkins
Here is output from Jenkins
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
No credentials specified
Cloning the remote Git repository
Cloning repository https://github.com/javaparser/javaparser-maven-sample.git
> C:\Program Files\Git\cmd\git.exe init C:\jenkins_slave\workspace\maven-example # timeout=10
Fetching upstream changes from https://github.com/javaparser/javaparser-maven-sample.git
> C:\Program Files\Git\cmd\git.exe --version # timeout=10
> C:\Program Files\Git\cmd\git.exe fetch --tags --force --progress https://github.com/javaparser/javaparser-maven-sample.git +refs/heads/*:refs/remotes/origin/*
> C:\Program Files\Git\cmd\git.exe config remote.origin.url https://github.com/javaparser/javaparser-maven-sample.git # timeout=10
> C:\Program Files\Git\cmd\git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> C:\Program Files\Git\cmd\git.exe config remote.origin.url https://github.com/javaparser/javaparser-maven-sample.git # timeout=10
Fetching upstream changes from https://github.com/javaparser/javaparser-maven-sample.git
> C:\Program Files\Git\cmd\git.exe fetch --tags --force --progress https://github.com/javaparser/javaparser-maven-sample.git +refs/heads/*:refs/remotes/origin/*
> C:\Program Files\Git\cmd\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> C:\Program Files\Git\cmd\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 646cebbe630ab346277b39680c2db6b367a06b00 (refs/remotes/origin/master)
> C:\Program Files\Git\cmd\git.exe config core.sparsecheckout # timeout=10
> C:\Program Files\Git\cmd\git.exe checkout -f 646cebbe630ab346277b39680c2db6b367a06b00
Commit message: "Make the jar executable"
> C:\Program Files\Git\cmd\git.exe rev-list --no-walk 646cebbe630ab346277b39680c2db6b367a06b00 # timeout=10
Parsing POMs
Modules changed, recalculating dependency graph
Established TCP socket on 53490
maven35-agent.jar already up to date
maven35-interceptor.jar already up to date
maven3-interceptor-commons.jar already up to date
[maven-example] $ java -cp C:\jenkins_slave\maven35-agent.jar;C:\maven\boot\plexus-classworlds-2.6.0.jar;C:\maven/conf/logging jenkins.maven3.agent.Maven35Main C:\maven C:\jenkins_slave\slave.jar C:\jenkins_slave\maven35-interceptor.jar C:\jenkins_slave\maven3-interceptor-commons.jar 53490
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\jenkins_slave\workspace\maven-example\pom.xml clean install -Dmaven.compiler.forceJavacCompilerUse=true
[INFO] Scanning for projects...
[HUDSON] Collecting dependencies info
[Office365connector] No webhooks to notify
[INFO]
[INFO] ------------< com.yourorganization:javaparser-maven-sample >------------
[INFO] Building javaparser-maven-sample 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ javaparser-maven-sample ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javaparser-maven-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javaparser-maven-sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\jenkins_slave\workspace\maven-example\target\classes
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class org.jfrog.hudson.maven2.MavenDependenciesRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[Office365connector] No webhooks to notify
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.874 s
[INFO] Finished at: 2019-09-23T04:01:08Z
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project javaparser-maven-sample: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_221\..\lib\tools.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[JENKINS] Archiving C:\jenkins_slave\workspace\maven-example\pom.xml to com.yourorganization/javaparser-maven-sample/1.0-SNAPSHOT/javaparser-maven-sample-1.0-SNAPSHOT.pom
channel stopped
[Office365connector] No webhooks to notify
Finished: FAILURE
And this is output from command line:[INFO] Scanning for projects...
[INFO]
[INFO] ------------< com.yourorganization:javaparser-maven-sample >------------
[INFO] Building javaparser-maven-sample 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ javaparser-maven-sample ---
[INFO] Deleting C:\jenkins_slave\workspace\maven-example\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javaparser-maven-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javaparser-maven-sample ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\jenkins_slave\workspace\maven-example\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ javaparser-maven-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\jenkins_slave\workspace\maven-example\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ javaparser-maven-sample ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ javaparser-maven-sample ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ javaparser-maven-sample ---
[INFO] Building jar: C:\jenkins_slave\workspace\maven-example\target\javaparser-maven-sample-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-shade-plugin:3.2.1:shade (default) @ javaparser-maven-sample ---
[INFO] Including com.github.javaparser:javaparser-core:jar:3.14.5 in the shaded jar.
[INFO] Attaching shaded artifact.
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ javaparser-maven-sample ---
[INFO] Installing C:\jenkins_slave\workspace\maven-example\target\javaparser-maven-sample-1.0-SNAPSHOT.jar to C:\Users\Administrator\.m2\repository\com\yourorganization\javaparser-maven-sample\1.0-SNAPSHOT\javaparser-maven-sample-1.0-SNAPSHOT.jar
[INFO] Installing C:\jenkins_slave\workspace\maven-example\pom.xml to C:\Users\Administrator\.m2\repository\com\yourorganization\javaparser-maven-sample\1.0-SNAPSHOT\javaparser-maven-sample-1.0-SNAPSHOT.pom
[INFO] Installing C:\jenkins_slave\workspace\maven-example\target\javaparser-maven-sample-1.0-SNAPSHOT-shaded.jar to C:\Users\Administrator\.m2\repository\com\yourorganization\javaparser-maven-sample\1.0-SNAPSHOT\javaparser-maven-sample-1.0-SNAPSHOT-shaded.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.794 s
[INFO] Finished at: 2019-09-23T04:02:40Z
[INFO] ------------------------------------------------------------------------
I just add the -Dmaven.compiler.forceJavacCompilerU se=true to "Goals and options" in Jenkins build job ...
... and in the command line for mvn.It would be useful to discover if one of those alone is enough to make the difference
ASKER
Yes, as the log in Jenkins, it still using JRE instead of JDK path.
Sorry i think i misunderstood. Since i saw that the Maven build was a success, i thought the problem is now solved
Well at least we have a clearer error message now. It's clear which files it is looking at and which JRE is involved:
Are you open to uninstalling that JRE? Since the JDK actually includes a JRE, having a separate installation of the JRE itself is unnecessary.
If you remove that completely from the system (and hence out of any path and registry settings etc.) it should force Java to always be using the Java\jdk...\jre\... files instead of the Java\jre...\ files.
And if it uses the JRE that runs inside the JDK, then when it looks for the lib\tools.jar it should find it.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project javaparser-maven-sample: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_221\..\lib\tools.jar -> [Help 1]
Are you open to uninstalling that JRE? Since the JDK actually includes a JRE, having a separate installation of the JRE itself is unnecessary.
If you remove that completely from the system (and hence out of any path and registry settings etc.) it should force Java to always be using the Java\jdk...\jre\... files instead of the Java\jre...\ files.
And if it uses the JRE that runs inside the JDK, then when it looks for the lib\tools.jar it should find it.
it should force Java to always be using the Java\jdk...\jre\... files instead of the Java\jre...\ files.Yes, that's possible but it suggests to me that it's using a wrong JAVA_HOME. That problem could re-emerge elsewhere if it's not solved
Yes, that's possible but it suggests to me that it's using a wrong JAVA_HOME. That problem could re-emerge elsewhere if it's not solvedTotally agree - but I'm hoping if we only have one location for Java, everything will normalize to that location.
At this point I'm wondering if JAVA_HOME is correct, but somehow Maven's properties aren't matching it.
E.g. This:
https://books.sonatype.com/mvnref-book/reference/resource-filtering-sect-properties.html
points out that Maven also has a java.home property which *should* be pointing to the same place as JAVA_HOME, but I wonder if that's the one referencing the JRE?
Clearly the JRE is getting picked up from somewhere and we still haven't figured out where, and I'm just hoping by removing it we can squash that from being possible.
OK. Actually one way or another, i've always found (unlike, say, Ant) Maven irritatingly mysterious. But according to your linked doc, there could be a settings file
kquoc, can you see (via cmd.exe) whether there's a file with
kquoc, can you see (via cmd.exe) whether there's a file with
notepad %USERPROFILE%\.m2\settings.xml
ASKER
@Doug: If i removed JRE, I cannot run the file slave-agent.jnlp to launch a slave node.
@CEHJ: there is no file in this path. This file is existing in maven home(C:\maven\conf), and I still not modify the content of file.
@CEHJ: there is no file in this path. This file is existing in maven home(C:\maven\conf), and I still not modify the content of file.
You should be able to remove the JRE, as long as you don't also remove the JDK, since the JDK includes a full JRE.
If you look at the install folder for the JDK, you can see there's a "jre" folder inside it. If that's on the path, you should be fine to launch the jnlp - although it's actually very interesting that this is how Jenkins does it's slave support as that may be where the JRE is appearing in all this.
If you're not sure it'll work - try renaming the existing JRE folder (without removing it), then make sure the JDK's folder is on the path and see if you can launch the jnlp. If that doesn't work you can rename the JRE folder back to its original location and no harm done. Safer than actually uninstalling it. But that should work. (My development laptop has no JRE on it - just the JDK and obviously I can run Java without issues).
If you look at the install folder for the JDK, you can see there's a "jre" folder inside it. If that's on the path, you should be fine to launch the jnlp - although it's actually very interesting that this is how Jenkins does it's slave support as that may be where the JRE is appearing in all this.
If you're not sure it'll work - try renaming the existing JRE folder (without removing it), then make sure the JDK's folder is on the path and see if you can launch the jnlp. If that doesn't work you can rename the JRE folder back to its original location and no harm done. Safer than actually uninstalling it. But that should work. (My development laptop has no JRE on it - just the JDK and obviously I can run Java without issues).
ASKER
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project javaparser-maven-sample: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_221\..\lib\tools.jar -> [Help 1]
In java folder have two folder jdk1.8.0_221 and jre1.8.0_221, as you can see in the log, Jenkins go to C:\Program Files\Java\jre1.8.0_221...This file is existing in maven home(C:\maven\conf), and I still not modify the content of file.Can you attempt the build again and then look at the timestamps of that file to verify it's being read. If you find it is, can you please attach it?
Well yes, that's the one you mentioned, isn't it? That ringed timestamp is not the one you need though. It won't be being modified. You need to look at last accessed (look at 'Properties')
ASKER
Hi CEHJ,
Well, I don't know how to check the last accessed of file. However, I try to destroy setting.xml file, and the build job complain about this. So Jenkins is using correct maven path.
Well, I don't know how to check the last accessed of file. However, I try to destroy setting.xml file, and the build job complain about this. So Jenkins is using correct maven path.
However, I try to destroy setting.xml file, and the build job complain about this.That's compelling but not conclusive
Can you try the following from an admin command prompt and tell me what you get?
fsutil behavior query disablelastaccess
ASKER
Yes, here is the output
DisableLastAccess = 1
OK if you issue
fsutil behavior set disablelastaccess 0
and then reboot, you should be able to view the last accessed stamp in Properties. You can toggle that again later, as it adds system overhead
Sorry for dropping off for a day here but I would like to suggest a theory to explain what is going wrong here based on what we know.
The important point to me is that when the JRE folder is renamed, the Jenkins slave-agent.jnlp file can't be launched. So this means that JNLP file is being started from the JRE, not the JDK. That then calls to maven to do the build and maven fails to find the javac compiler.
So to me the issue is that we need slave-agent.jnlp to be launched from the JDK - not the JRE.
To take this a step further, I believe JNLP files are launched by the "javaws" executable. On Windows "javaws.exe".
So the question is which "javaws.exe" file is being used to launch slave-agent.jnlp?
If you run "cmd" on the machine and type "where javaws" what do you get?
For me I get:
Note that the JDK is first - because it's first on my path. Is it first for you?
Also in Windows there is the concept of a "file association".
If you right click on the slave-agent.jnlp file and choose "Properties" it should open a dialog like the
properties.jpg I attached.
Within that you can choose "Change" next to "Opens with", scroll to the bottom of the dialog that opens and select "Look for another app on this PC". Then you can browse to the JDK's folder, then "bin" within it and then click on that "javaws.exe"
I would do both - make sure that the first response to "where javaws" is the JDK's javaws. And also make sure that the Windows file association points to the JDK's "javaws.exe" file.
Then try launching it again and see if we're making any progress.
Doug
The important point to me is that when the JRE folder is renamed, the Jenkins slave-agent.jnlp file can't be launched. So this means that JNLP file is being started from the JRE, not the JDK. That then calls to maven to do the build and maven fails to find the javac compiler.
So to me the issue is that we need slave-agent.jnlp to be launched from the JDK - not the JRE.
To take this a step further, I believe JNLP files are launched by the "javaws" executable. On Windows "javaws.exe".
So the question is which "javaws.exe" file is being used to launch slave-agent.jnlp?
If you run "cmd" on the machine and type "where javaws" what do you get?
For me I get:
C:\Users\Doug>where javaws
C:\Java\jdk1.8.0_144\bin\javaws.exe
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\javaws.exe
C:\ProgramData\Oracle\Java\javapath\javaws.exe
Note that the JDK is first - because it's first on my path. Is it first for you?
Also in Windows there is the concept of a "file association".
If you right click on the slave-agent.jnlp file and choose "Properties" it should open a dialog like the
properties.jpg I attached.
Within that you can choose "Change" next to "Opens with", scroll to the bottom of the dialog that opens and select "Look for another app on this PC". Then you can browse to the JDK's folder, then "bin" within it and then click on that "javaws.exe"
I would do both - make sure that the first response to "where javaws" is the JDK's javaws. And also make sure that the Windows file association points to the JDK's "javaws.exe" file.
Then try launching it again and see if we're making any progress.
Doug
ASKER
Hi Doug,
This is what I got in cmd
n, but it show nothing.
I just found a solution to solve my issue. Don't know why I have to add this, but it's working.
This is what I got in cmd
C:\Users\Administrator>where javaws
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\javaws.exe
C:\Program Files\Java\jdk1.8.0_221\bin\javaws.exe
I tried to open slave-agent.jnlp by javaws.exe in C:\Program Files\Java\jdk1.8.0_221\biI just found a solution to solve my issue. Don't know why I have to add this, but it's working.
Go to 'Environment variables' section (again in your Node's configuration only). Click on Add.
Name: java.home
Value: C:\Program Files\Java\jdk1.8.0_221\jre
Thanks.
I just found a solution to solve my issue. Don't know why I have to add this, but it's working.Well of course, it's quite possible that settings.xml IS being used and has just been edited by that GUI you used ;) You should find out
>> but it's working.
Sweet! Glad to finally get to the end of this quest.
It's been a long and crazy one - but excellent that you finally got it solved.
Doug
Sweet! Glad to finally get to the end of this quest.
It's been a long and crazy one - but excellent that you finally got it solved.
Doug
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your PATH setting should start as follows:
Open in new window
(assuming of course that the bin directory exists there, and contains java.exe and more importantly javac.exe)