java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher

Recently when I am trying to run some Maven scripts, I am  getting this exception:

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

Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

Could not find the main class: org.codehaus.plexus.classworlds.launcher.Launcher.  Program will exit.

After spending some time trying various combinations , I found that this is because I have both M2_HOME and M3_HOME set in my environment variables.Once I removed M2_HOME from my environment variables, I could get this working back again.May be this could save some serious time for  some one.


Comments:

You saved my day!

Posted by hari on April 25, 2011 at 10:21 AM IST #

Thanx! This worked perfectly and fixed the problem

Posted by Steven on April 27, 2011 at 06:31 AM IST #

Thanks so much!! This was a life saver! :-)

Posted by NN on May 11, 2011 at 09:48 PM IST #

Dude, you rock! Thanks a million.

Posted by Mike on May 15, 2011 at 04:53 AM IST #

God bless you. You saved my weekend.

Posted by guest on May 20, 2011 at 11:10 AM IST #

Excellent random thought. Thanks!

Posted by Bols on June 03, 2011 at 05:38 AM IST #

Thank you very much.

Posted by guest on June 06, 2011 at 06:29 AM IST #

This saved me lot of time, thanks

Posted by guest on June 13, 2011 at 08:47 PM IST #

hi guys am facing the same problem, am own root and have installed maven 2.2.1 from source
when i type maven --version

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/classworlds/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.classworlds.Launcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.codehaus.classworlds.Launcher. Program will exit.

my env is like this

MAVEN_OPTS=-Xms25m
MAIL=/var/spool/mail/root
PATH=/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src/bin:/usr/local/apache-maven/apache-maven-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/jdk/bin:/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src/bin/
PWD=/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src/bin
JAVA_HOME=/usr/local/jdk
LANG=en_US.utf8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HISTCONTROL=ignoredups
M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src
M2=/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src/bin

Posted by charlie on June 28, 2011 at 11:12 AM IST #

hi guys am facing the same problem, am own root and have installed maven 2.2.1 from source
when i type maven --version

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/classworlds/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.classworlds.Launcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.codehaus.classworlds.Launcher. Program will exit.

my env is like this

MAVEN_OPTS=-Xms25m
MAIL=/var/spool/mail/root
PATH=/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src/bin:/usr/local/apache-maven/apache-maven-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/jdk/bin:/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src/bin/
PWD=/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src/bin
JAVA_HOME=/usr/local/jdk
LANG=en_US.utf8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HISTCONTROL=ignoredups
M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src
M2=/usr/local/apache-maven/apache-maven-2.2.1/apache-maven/src/bin

Posted by guest on June 28, 2011 at 11:13 AM IST #

thx sloved my issue

Posted by guest on June 30, 2011 at 07:42 AM IST #

Thanks a lot! Same issue here on my Mac!

Best regards,
Kai

Posted by Kai Wähner on July 01, 2011 at 08:23 PM IST #

thanks so much for this post... saved me a ton of time !

Posted by ddaugher on July 03, 2011 at 12:59 AM IST #

I'm having a similar problem as the original post here and getting the same exact error, but I have yet to be able to run maven as I get this just trying to use the command "mvn -version". I have just recently installed Maven 3.0.3 and am using jdk1.6.0_02. They are both in the same directory and my env looks like this: JAVA_HOME C:\Program Files\Java\jdk1.6.0_02, CLASSPATH .;C:\Program Files\Java\jdk1.6.0_02 M2_HOME C:\Program Files\Maven3\apache-maven-3.0.3\apache-maven\src and PATH C:\Mercurial\Python27\MinGW\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\PC-Doctor for Windows\services;C:\Program Files\QuickTime\QTSystem;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE;%M2_HOME%\bin;%JAVA_HOME%\bin

Hope someone can help. I've been struggling with trying to get this to work for a couple of months and just starting to learn configuration management. Thanks in advance.

Posted by guest on August 05, 2011 at 12:41 AM IST #

Saved my day too! Thanks for the post.

Posted by Ravi Balla on August 30, 2011 at 07:56 PM IST #

thanks; saved a lot of time

Posted by bala on October 07, 2011 at 05:34 PM IST #

I have a similar problem, in path env variable, I had C:\apache-maven-2.2.1\bin and C:\springsource\apache-maven-3.0.3\bin, after I removed C:\apache-maven-2.2.1\bin, I was able to use mvn.

Posted by guest on October 15, 2011 at 02:25 PM IST #

it is great!
Thank you very much

Posted by guest on December 05, 2011 at 07:38 AM IST #

Just what I needed...thanks!

Posted by guest on December 07, 2011 at 05:23 PM IST #

Yes, quite a time saver -- thanks!

Posted by guest on December 16, 2011 at 09:20 PM IST #

this is exactly what I needed thank you saved my time. One point I wnat to add I have grails path also in my path that is also one of the causes it's failing

Posted by Krupa on December 21, 2011 at 06:41 PM IST #

thnks very much...solved my issue...!

Posted by guest on December 27, 2011 at 10:42 AM IST #

For me, I had to simply modify the M2_HOME variable to point to the new maven path. Then mvn worked ok. Thanks for your post.

Posted by guest on January 07, 2012 at 06:47 AM IST #

Thanks a lot! I'm another reader you helped with this.

Posted by guest on January 19, 2012 at 10:33 AM IST #

Thanks man I had to change M2 and M2_HOME to M3 and M3_HOME respectively.

Posted by guest on January 28, 2012 at 04:28 AM IST #

worked for me after I executed this on the command line to remove the M2_HOME env variable:
unset M2_HOME
(where my .bashrc file had: 'M2_HOME=/usr/local/maven' ... 'export M2_HOME')

(Mac OS, installing Maven version 3, online docs I'm following spelled out creating env variable M2_HOME; looks like it should be M3_HOME instead)

thanks!

Posted by guest on February 01, 2012 at 12:50 PM IST #

worked for me after I executed this on the command line to remove the M2_HOME env variable:
unset M2_HOME
(where my .bashrc file had: 'M2_HOME=/usr/local/maven' ... 'export M2_HOME')

(Mac OS, installing Maven version 3, online docs I'm following spelled out creating env variable M2_HOME; looks like it should be M3_HOME instead)

thanks!

Posted by guest on February 01, 2012 at 12:50 PM IST #

Thank you so much!you save my life

Posted by guest on February 07, 2012 at 08:22 AM IST #

I am facing the same problem while installing DSpace in centOS. I am very new to linux. If anyone give the steps to remove M2_HOME env variable in a bit detail then it would be really helpful.

Posted by Rahul Soni on February 25, 2012 at 11:16 AM IST #

I am facing the same problem while installing DSpace in centOS. I am very new to linux. If anyone give the steps to remove M2_HOME env variable in a bit detail then it would be really helpful.

Posted by Rahul Soni on February 25, 2012 at 11:17 AM IST #

thanks mate, you saved me a lot of time :-)

Cheers

Posted by guest on February 29, 2012 at 03:36 AM IST #

Super! This fixed my problem with running tests in the Spring Roo example.

Posted by guest on March 28, 2012 at 12:42 AM IST #

thanks so much!you have saved me a ton of time digging around in random corners.

Posted by guest on April 19, 2012 at 07:11 AM IST #

Thanks, save me also a lots of time. Thanks again.

Posted by guest on April 25, 2012 at 12:22 AM IST #

Hi, Im facing same issue but not yet resolved, please advice: im getting below: exception:
C:\Users\Poojitha>mvn -version
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/c
lassworlds/launcher/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.lau
ncher.Launcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.codehaus.plexus.classworlds.launcher.Launcher
. Program will exit.

My Environment variables are below:
M3_HOME : C:\VasuBackUp\Softwares\Java-All\apache-maven-3.0.4\apache-maven\src
PATH : D:\oraclexe\app\oracle\product\10.2.0\server\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\PROGRA~1\DISKEE~1\DISKEE~1\;%JAVA_HOME%\bin;%CATALINA_HOME%\bin;%M3_HOME%\bin;

Posted by Vasu on May 05, 2012 at 03:05 AM IST #

I got the same thing, didn't have the M2_HOME or M3_HOME set, however somehow my maven lib folder became hidden. Make sure everything in your maven folder is accessible (on windows view properties, if your on mac or linux you probably won't have this problem because ur less likely to be bucked up the grass on those oses)

Anyway here's proof that fixed if for me:

C:\apps\java\m\***>mvn clean
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
C:\apps\java\m\***>mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ********* 1.17-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom

etc bucking etc

Posted by guest on May 13, 2012 at 12:47 AM IST #

Thanks, still saving lives!

Posted by guest on June 01, 2012 at 07:04 PM IST #

renamng Of M2-HOME to M3-HOME worked for me, thnks friend

Posted by guest on June 29, 2012 at 02:59 PM IST #

export M3_HOME=/opt/apache-maven-3.0.4
export M3=$M3_HOME/bin
export PATH=$M3:$PATH

This would solve the problem :)

Posted by guest on July 01, 2012 at 09:50 PM IST #

i have zipped and unzipped the maven setup file and i get the above error how can i fix the issue

thanks in advance

Posted by guest on July 09, 2012 at 11:35 PM IST #

You win one (1) internet.

Posted by guest on July 30, 2012 at 09:56 AM IST #

Got exactly the same error. Tried all the solutions in the comments finally this link got me through. http://oodt.apache.org/components/maven/filemgr/user/basic.html

Posted by guest on August 18, 2012 at 05:53 AM IST #

Thx a lot :)that helps me :)

Posted by guest on August 29, 2012 at 06:28 PM IST #

you save my day!

Posted by guest on September 05, 2012 at 03:51 AM IST #

Thanks it helped me. In my case i had another M2_HOME under system Environment variables list that made the issue. The same i deleted and now working fine.

Posted by Pammi on December 12, 2012 at 04:44 PM IST #

i love youuu

Posted by guest on May 03, 2013 at 06:59 PM IST #

Hey! Thanks a lot, you save my day :D

Posted by guest on June 28, 2013 at 03:32 AM IST #

You saved my day

Posted by guest on July 18, 2013 at 05:38 PM IST #

Save my day too! My problem was that Mac OS updated Maven, but din't set M3_HOME variable. I only had M2_HOME...

Posted by Ciprian on July 23, 2013 at 06:45 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

This is my personal blog.All the information here reflects my own thoughts and feelings and should not be taken as official information from Oracle.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today