Eleeist
Eleeist

Reputation: 7041

Pre-installed Maven on Mac OS X gives java.lang.ClassNotFoundException

I tried to run pre-installed Maven with mvn command and get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher

Running latest Mac OS X Mountain Lion and Java.

Upvotes: 1

Views: 2680

Answers (2)

ram
ram

Reputation: 777

Please check which version of Maven & Java you are using.

Your use case looks similar to the following blog post found online.

http://cyntech.wordpress.com/2011/03/09/maven-2-error/

Upvotes: 2

Roy Lyons
Roy Lyons

Reputation: 131

That looks very familiar. I have seen that when M2_HOME was set to a Maven2 installation.

Do you have M2_HOME, or MAVEN_HOME set? This could be the culprit.

There are some pretty major bugs in maven 3.0.3. There are also really nice performance gains in 3.0.4 related to the maven http wagon, including connection pooling. If you find that your builds are running slower, do a mvn --version. The version that ships with Lion is 3.0.3.

To fix this, do the following:

brew install maven sudo unlink /usr/share/maven cd /usr/share/ sudo ln -s /usr/local/Cellar/maven/3.0.4 maven

Making sure that the M2_HOME and MAVEN_HOME variables aren't set is pretty key to issues like this (for some reason Mac OS X doesn't need them and it causes issues). That's the usual culprit. I would encourage you to upgrade to 3.0.4 as well though for the httpclient improvements if nothing else.

Upvotes: 2

Related Questions