Maven 2 -- classworlds.Launcher not found

The other day I suddenly started getting this error when running maven 2 on my gentoo box.

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

The great oracle of google wasn't much help. I finally figured out that I had installed, or emerged in gentoo parlance, maven and this was causing a conflict with the maven I had installed in my home directory. I had edited my .bashrc file with the necessary environment variables but now bash was finding mvn on the /usr/bin path rather than in my home directory.

I uninstalled, or unmerge, maven-bin and everything worked fine again. In general I find it best to install all your java related build tools by hand in your home directory on Linux systems. This avoids all those permission issue which are designed to protect production system but are just an annoyance when developing..

When you are developing you don't want to have to su to root just to deploy your war. I usually have eclipse, maven and jetty installed in my home directory. It enables me to install eclipse plugins, upgrade maven etc without having to wait for the distro to catch up.


You really helped me with this comment. I wouldnt find out myself that I had two mavens by mistake!!!
Thanks man!

Hey, I am having the same problem I type in "mvn" and I get:

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

What did you do to your file? I don't have a bash_src.



I had this problem after installing maven2 using JDK 1.6, all on a mac (leopard). To fix, all I did was run "sudo mvn --version". And it worked, I guess it was a permissions thing for me.

Have you figured out what the problem was and how to run mvn without root privileges? I have the same issue, but I'd like to be able not to use root.

If you are setting the M2_HOME variable in .profile or something, don't.

Remove your M2_HOME variable, log out, log back in, and try again.

I was getting this same error, did that, and then I was able to use maven2 without being root. (Using Mint, an Ubuntu variation).

Many thanks, works for me on xubuntu, 1.6 iced tea also ;)


The issiue showed up when i configured netbeans to work with maven. Netbeans moved the classworlds jar from $M2_HOME/bin to $M2_HOME/bood dir in the maven installation directory. Adding the new path to java classpath solved the problem.... that netbeans wrecks havoc on my pc :-/


Setting M2_HOME works fine for me. However, if you set it to the wrong location you will get this error.