Maven task failing with (possibly) environment related Laucher error

Patrick Foster January 9, 2015

I am running a maven based test suite as a task in stand alone Bamboo.   I am having problems with a new server that I am standing up where the task fails with:

Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

The same script runs correctly if invoked from a command line.  If I got this error there (the command line), I would expect that the environment was not properly setup.  I have tried setting the M2_HOME variable and others from the local environment box that's part of the task.   The error log shows that those are not taking (I see M2_HOME=/usr instead of M2_HOME=/usr/share/maven, for example).   Where should I be looking to fix this problem?  

5 answers

1 vote
Jason Hill March 16, 2016

I was experiencing the same problem and the fix for me was changing the executable path.

On Ubuntu 12.04 the correct path for the maven executable is /usr/share/maven. Bamboo then correctly adds bin/mvn for the executable and sets M2_HOME to usr/share/maven as it should. 

0 votes
Marc Rodriguez Sanz January 6, 2016

Hi @Krystian Brazulewicz,

I am having exactly the same problem than @Patrick Foster.

 

The information shown in the execution log also shows:

M2_HOME=/usr

 

The location of maven on our Bamboo server is '/usr/bin/mvn'

So I tried to modify the configuration of mvn within the server capabilities. After setting the whole mvn path, I get this error:

 Unable to find executable at /usr/bin/mvn/bin/mvn. Will try to run it anyway

This error somehow shows that Bamboo automatically adds '/bin/mvn' to the path configured in the server capabilities.

 

While searching for more information I could find this open issue: https://jira.atlassian.com/browse/BAM-15767

 

Is there any workaround you could provide us meanwhile the problem is solved?

 

Thanks for your help and best regards!

Marc

 

0 votes
Krystian Brazulewicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2015

@Patrick Foster

This part of the log:

M2_HOME=/usr

can suggest that there's something wrong with your capabilities. Can you please attach screenshot of your maven task configuration and screenshot with the server/agent capabilities?

0 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 9, 2015

Hello Patrick,

Thank you for your question.

When you set up M2_HOME as a system environment variable, was Bamboo running already? If so, I would kindly ask you to stop and start Bamboo once again, please. By doing that, Bamboo should pick up Maven capabilities automatically.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

 

Patrick Foster January 9, 2015

I stopped Bamboo, checked for the desired variables, restarted bamboo, re-ran the test and continued to get this: Beginning to execute external process for build 'TestSuite - AT - CodeCheckout #4 (TS-AT-COD-4)' ... running command line: /usr/bin/mvn --batch-mode -Djava.io.tmpdir=/test/bamboo/bamboo-home/temp/TS-AT-COD clean test ... in: /test/bamboo/bamboo-home/xml-data/build-dir/131073/TS-AT-COD ... using extra environment variables: bamboo_capability_system_jdk_JDK_1_7=/usr/lib/jvm/java-7-oracle JAVA_HOME=/usr/lib/jvm/java-7-oracle bamboo_planRepository_type=bb bamboo_shortPlanName=AT bamboo_planKey=TS-AT bamboo_planRepository_1_branchName=master bamboo_capability_system_builder_mvn3_Maven_3_0_5=/usr/share/maven bamboo_repository_1671179_previous_revision_number=d792fb145841d1b86c3f8363a20487be06b94057 bamboo_shortPlanKey=AT bamboo_shortJobKey=COD bamboo_build_working_directory=/test/bamboo/bamboo-home/xml-data/build-dir/131073/TS-AT-COD bamboo_repository_1671179_revision_number=d792fb145841d1b86c3f8363a20487be06b94057 bamboo_repository_revision_number=d792fb145841d1b86c3f8363a20487be06b94057 M2_HOME=/usr bamboo_planName=TestSuite - AT bamboo_buildResultsUrl=http://archive.touchplan.io:8085/browse/TS-AT-COD-4 bamboo_buildResultKey=TS-AT-COD-4 bamboo_planRepository_revision=d792fb145841d1b86c3f8363a20487be06b94057 bamboo_capability_system_jdk_JDK_1_7_0_65=/usr/lib/jvm/java-7-oracle bamboo_capability_system_git_executable=/usr/bin/git bamboo_repository_previous_revision_number=d792fb145841d1b86c3f8363a20487be06b94057 bamboo_buildKey=TS-AT-COD bamboo_working_directory=/test/bamboo/bamboo-home/xml-data/build-dir/131073/TS-AT-COD bamboo_agentWorkingDirectory=/test/bamboo/bamboo-home/xml-data/build-dir/131073 bamboo_buildPlanName=TestSuite - AT - CodeCheckout bamboo_repository_1671179_name=AutoTest bamboo_repository_name=AutoTest useMavenReturnCode=false bamboo_repository_1671179_branch_name=master bamboo_resultsUrl=http://archive.touchplan.io:8085/browse/TS-AT-COD-4 bamboo_planRepository_1_revision=d792fb145841d1b86c3f8363a20487be06b94057 bamboo_ManualBuildTriggerReason_userName=bamboo bamboo_planRepository_1_type=bb bamboo_planRepository_1_previousRevision=d792fb145841d1b86c3f8363a20487be06b94057 MAVEN2_HOME=/usr bamboo_planRepository_1_name=AutoTest bamboo_capability_system_builder_mvn3_Maven3=/usr bamboo_planRepository_branchName=master bamboo_capability_system_jdk_JDK=/usr/lib/jvm/java-7-oracle bamboo_shortJobName=CodeCheckout bamboo_repository_branch_name=master

rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 9, 2015

Hello Patrick, Thank you for your update. We had some issues related to Maven v3.0.5. Due to that, I would kindly ask you to upgrade Maven to v3.2.1 for example. Once the upgrade is done, I would kindly ask you to go to (Bamboo administration >> Build resources >> Server Capabilities) and hit (Detect server capabilities). Please let me know if Bamboo picks up the new Maven installation and the location set up on $M2_HOME. — Kind regards, Rafael P. Sperafico Atlassian Support

0 votes
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 9, 2015

This error can happen when the wrong version of Maven is invoked, so yes it sounds like you are on the right track in trying to get your bamboo agent to launch Maven from the correct location.

If you're using the Maven task type, then you can configure the agent to launch the correct Maven executable by configuring the Maven capability on the agent (see https://confluence.atlassian.com/display/BAMBOO/Defining+a+new+executable+capability)

 

 

 

Patrick Foster January 9, 2015

I tried this tactic and it had no discernible effect, assuming that I did things correctly.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events