Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher when running bash file to build the project

I have maven 2 installed. When I use mvn clean or mvn install in the app root it works fine.

But when I am trying to use maven install inside a bash script, I got the above exception:

This is my script:

#!/bin/sh
#dirname='/home/myuser/workspace/myapp'
DIRECTORY=$(cd `dirname $0` && pwd)
cd  $DIRECTORY
mvn install -s resources/settings.xml $1

it was working fine with maven 3, but after I installed maven 2 and configured it, it stopped working and gave me above exception. I don't know what is the problem, since the regular build, mvn install works, but building from the script doesn't work.

like image 267
Mahmoud Saleh Avatar asked Jun 01 '11 09:06

Mahmoud Saleh


2 Answers

Couple of possibilities...

  • One, as posted here, you have both M2_REPO and M3_REPO variables defined.
  • Or you are facing this issue related to maven3 and M2_HOME
  • The other is that somehow the JRE is getting used instead of JDK when run from the batch file!
like image 181
Raghuram Avatar answered Nov 14 '22 03:11

Raghuram


I had this issue when my M2_HOME environment variable points to an incorrect location.

Try to:

$ cd $M2_HOME
like image 30
sourcerebels Avatar answered Nov 14 '22 05:11

sourcerebels