Maven task failing with (possibly) environment related Laucher error
Asked by Patrick Foster:

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?


Answers:
author: Jason Hill
body: 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.


author: Marc Rodriguez Sanz
body: 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


author: Krystian Brazulewicz
body: @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?


author: rsperafico
body: 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

comments: author: Patrick Foster
body: 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-oracleJAVA_HOME=/usr/lib/jvm/java-7-oraclebamboo_planRepository_type=bbbamboo_shortPlanName=ATbamboo_planKey=TS-ATbamboo_planRepository_1_branchName=masterbamboo_capability_system_builder_mvn3_Maven_3_0_5=/usr/share/mavenbamboo_repository_1671179_previous_revision_number=d792fb145841d1b86c3f8363a20487be06b94057bamboo_shortPlanKey=ATbamboo_shortJobKey=CODbamboo_build_working_directory=/test/bamboo/bamboo-home/xml-data/build-dir/131073/TS-AT-CODbamboo_repository_1671179_revision_number=d792fb145841d1b86c3f8363a20487be06b94057bamboo_repository_revision_number=d792fb145841d1b86c3f8363a20487be06b94057M2_HOME=/usrbamboo_planName=TestSuite - ATbamboo_buildResultsUrl=<http://archive.touchplan.io:8085/browse/TS-AT-COD-4>bamboo_buildResultKey=TS-AT-COD-4bamboo_planRepository_revision=d792fb145841d1b86c3f8363a20487be06b94057bamboo_capability_system_jdk_JDK_1_7_0_65=/usr/lib/jvm/java-7-oraclebamboo_capability_system_git_executable=/usr/bin/gitbamboo_repository_previous_revision_number=d792fb145841d1b86c3f8363a20487be06b94057bamboo_buildKey=TS-AT-CODbamboo_working_directory=/test/bamboo/bamboo-home/xml-data/build-dir/131073/TS-AT-CODbamboo_agentWorkingDirectory=/test/bamboo/bamboo-home/xml-data/build-dir/131073bamboo_buildPlanName=TestSuite - AT - CodeCheckoutbamboo_repository_1671179_name=AutoTestbamboo_repository_name=AutoTestuseMavenReturnCode=falsebamboo_repository_1671179_branch_name=masterbamboo_resultsUrl=<http://archive.touchplan.io:8085/browse/TS-AT-COD-4>bamboo_planRepository_1_revision=d792fb145841d1b86c3f8363a20487be06b94057bamboo_ManualBuildTriggerReason_userName=bamboobamboo_planRepository_1_type=bbbamboo_planRepository_1_previousRevision=d792fb145841d1b86c3f8363a20487be06b94057MAVEN2_HOME=/usrbamboo_planRepository_1_name=AutoTestbamboo_capability_system_builder_mvn3_Maven3=/usrbamboo_planRepository_branchName=masterbamboo_capability_system_jdk_JDK=/usr/lib/jvm/java-7-oraclebamboo_shortJobName=CodeCheckoutbamboo_repository_branch_name=master


author: rsperafico
body: 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. SperaficoAtlassian Support


author: Joe Clark
body: 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>)

comments: author: Patrick Foster
body: I tried this tactic and it had no discernible effect, assuming that I did things correctly.


Tags: bamboo-administration