1
votes

I have a jenkins job that checks out code from TFS and executes a test class using testng.xml

I have Maven properly installed in my machine in C:\JenkinsDependencies\apache-maven

It has mvn.bat file in its bin folder.

But when I execute my job, it fails with the following error.

Checking for pre-build [TFS_LN_Mobile] $ cmd.exe /C '"C:\JenkinsDependencies\apache-maven\bin\mvn.bat test && exit %%ERRORLEVEL%%"'

Error occurred during initialization of VM

java/lang/NoClassDefFoundError: java/lang/Object

Build step 'Invoke top-level Maven targets' marked build as failure

Checking for post-build Finished: FAILURE

Below is the configuration of my jenkins job: enter image description here I manually executed a batch command as follows:

cd "C:\JenkinsRoot\workspace\TFS_LN_Mobile"
mvn test -DsuiteXmlFile=testng.xml

This works fine.

1
do you have your JAVA_HOME and M2_HOME variables set for jenkins user?ilj
On the slave machine where the code will be check out, I have set MAVEN_HOME AND JAVA_HOME set. What should M2_HOME point to?Rameshwar
M2_HOME=/path/to/maven-3.2.5, so that when it does PATH=PATH:M2_HOME/bin, your mvn.bat is there.ilj
Should I append %M2_HOME%\bin in my PATH?Rameshwar
from your error message, it looks like Jenkins is able to find your maven. so just setting JAVA_HOME and adding it to PATH should be fine.ilj

1 Answers

1
votes

mvn.bat is a batch script. you can try adding trace of it's variables after steps that might produce this error. take a look at this: Is there any way to trace through the execution of a batch file?