ERROR: Failed to parse POMs, Jenkins

This article contains an error that occurred while building a Maven project with the Jenkins server. My code is present in the Github repository and it’s a Java code. I have configured Jenkins to pull the code from the Git repository and build.

Jenkins project configuration details

Used Github as a source code management.

 

For JDK, I have installed it with the “yum” package manager ( Used Amazon Linux Operating sysytem) and enabled it in the Jenkins server as seen in the screenshot.

I have confirmed that all the required code files and pom.xml files are in place and triggered the build from the Jenkins dashboard but it is failed with the below error message.

Error:

The complete error message that got from the Jenkins console is given below.

Started by user admin

Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/First_Maven_project
No credentials specified
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url 
https://github.com/techiescorner/Hello-World-Code.git
 # timeout=10
Fetching upstream changes from 
https://github.com/techiescorner/Hello-World-Code.git
 > git --version # timeout=10
 > git fetch --tags --progress -- 
https://github.com/techiescorner/Hello-World-Code.git
 +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 0d4d43993b3f7d527b69249f1dbb15f5b2830751 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 0d4d43993b3f7d527b69249f1dbb15f5b2830751 # timeout=10
Commit message: "sample java code"
First time build. Skipping changelog.
Parsing POMs
Established TCP socket on 44039
[First_Maven_project] $ /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.47.amzn1.x86_64/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/opt/apache-maven/boot/plexus-classworlds-2.6.0.jar:/opt/apache-maven/conf/logging jenkins.maven3.agent.Maven35Main /opt/apache-maven /var/cache/jenkins/war/WEB-INF/lib/remoting-3.36.1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar 44039
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.47.amzn1.x86_64/bin/java" (in directory "/var/lib/jenkins/workspace/First_Maven_project"): error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at hudson.Proc$LocalProc.<init>(Proc.java:250)
	at hudson.Proc$LocalProc.<init>(Proc.java:219)
	at hudson.Launcher$LocalLauncher.launch(Launcher.java:937)
	at hudson.Launcher$ProcStarter.start(Launcher.java:455)
	at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:280)
	at hudson.maven.ProcessCache.get(ProcessCache.java:236)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:804)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
	at hudson.model.Run.execute(Run.java:1853)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:427)
Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.forkAndExec(Native Method)
	at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
	at java.lang.ProcessImpl.start(ProcessImpl.java:134)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 12 more
Finished: FAILURE

After digging the error I found that Jenkins is not able to use the Java SDK which we set in the Global Configuration, so as a workaround, I have changed the JDK installation as automatically.

Resolution for the error

Log in to the Jenkins server and click on “Manage Jenkins” from the left-side panel. Select Global Tool Configuration and click on the JDK installation button.

Give a name for the installation and tick the “Install Automatically”. Next, click on the “Add-installer” button and from the pop-up window, select “Install Oracle java SE from the website” option.

 

To installĀ  JDK from the oracle website you need an account with Oracle Technologies (https://login.oracle.com/mysso/signon.jsp ). Configure the installer as follows and enter your credentials in the pop-up window.

Click apply and then save.

Try to build the code again, and this time you can see Jenkins server try to install the JDK from the Oracle web site.

 

It took a few minutes to complete the build process but completed successfully.

Leave a Reply

Your email address will not be published.