Maven 2: NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher

If you were like me and have just installed Apple’s latest Java 6 update and found that Maven 2 doesn’t work, then this might be of some help.

After installing the latest Java update this morning, I returned to what I was working on. I’m working on a community source project at the moment on Github so I usually update and rebuild before continuing my work but I was horrified to get the following error when I tried to run Maven 2:

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

I immediately checked my java version and first discovered that the Apple update had deleted my Java 1.5 install (I require 1.5 for another project I’m on), so that put me in a bad mood to begin with.

Once I’d fixed the java issue, I tried again but nothing had changed. I googled and read newsgroup site after forum site of people getting this problem but the main consistency was that it was an incompatibility between Maven 2 and 3 and the M2_HOME environment variable. I didn’t think this was my problem as I had not installed Maven 3.

Thanks to a good friend of mine, Steve, he directed me to where my MBP thought maven was being run from by using the ‘which’ command.

$ which mvn

When I investigated this, it revealed something very interesting…

$ ls -la /usr/bin/mvn
lrwxr-xr-x  1 root  wheel  24  9 Mar 12:09 /usr/bin/mvn -> /usr/share/maven/bin/mvn
$ cd /usr/share/
$ ls -la maven
lrwxr-xr-x    1 root   wheel    16  9 Mar 12:09 maven -> java/maven-3.0.2

It looks like that included with the OSX Java update, it installed maven 3.  Now, this is all fine and dandy, but the projects I’m working on don’t run on Maven 3 just yet, so I need to switch this back to my actual Maven 2 install.

$ sudo mv maven maven.temp
$ sudo ln -s /opt/apache-maven-2.2.1/ maven
$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-07 05:16:01+1000)
Java version: 1.5.0_26
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.6" arch: "i386" Family: "unix"


Once again, thanks to Steve Swinsburg for his assistance. Make sure you check out his blog for cool development posts.


About Cyntech
Applications programmer, Father, Gamer, Soccer fanatic.

20 Responses to Maven 2: NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher

  1. Pingback: Java update broke my Maven | steveswinsburg

  2. Instead of a symlink, you might just put the maven bin in your path before /usr/bin. As a rule, I don’t like to muck with the default OS X install… e.g.:

    export M2_HOME=/usr/local/apache-maven-2.2.1
    export PATH=$M2_HOME/bin:$PATH


  3. Cyntech says:

    Thanks Lance, I’ll give that a try.


  4. Pingback: Mac OS X + Downgrade de Maven = Problemas! | Endrigo Antonini

  5. Michael Bedward says:

    Thanks very much for posting this – it’s just saved me a lot of time. I went for the path option as suggested by Lance.


  6. Jonas says:

    Thanks for the post man. Saved me a lot of time!


  7. Indiana Bob says:

    Thank you very much for posting this, worked like a charm.



  8. Maryam says:

    Thanks! Such a time saver! 🙂


  9. José Luis says:

    Thanks for the post. I finally could figure out where was my problem.


  10. dayal says:

    Thanks, worked perfectly!!


  11. Fred Curry says:

    Thanks so much. I was only able to run Maven through Eclipse, which really didn’t make any sense to me. This will make life a lot easier.


  12. sun says:

    very helpful!


  13. Jeremy says:

    Nice blog, worked perfectly for me too. Thanks.


  14. Andrei says:

    Thank you, you saved a bunch of my neurons!


  15. milikicnNikola says:

    Thanks man! I’ve spent the whole day struggling with this issue and your post came as a saver.


  16. smarmalade says:

    apple can be an a$$ sometimes


  17. tvs says:

    Thank you. I’ve to use cyntech’s idea to find the path where maven is available and use lance option to set the path correctly. It worked
    export M2_HOME=/usr/share/java/maven-3.0.4
    export PATH=$M2_HOME/bin:$PATH


  18. praveen says:

    Thanks a lot! This saved my day.


  19. Hang Pan says:

    Thanks for posting this, I got this problem as well.
    And then I set MAVEN2_HOME instead of M2_HOME, the issue is gone.


  20. kanadsante says:

    Thanks for this post! I am using Ubuntu 10.04 LTS and was experiencing inconsistent behaviour even after setting correct Maven home variables in PATH. There was a /usr/bin/mvn which was causing problems.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: