Maven 2 -- classworlds.Launcher not found

2011-08-18  籽藤 

以下内容源自:http://www.permeance.com.au/web/terry.mueller/home/-/blogs/maven2-reports-java-lang-noclassdeffounderror:-org-codehaus-classworlds-launcher

-------------------------------------------------------------------------

I have installed Fedora 12 beta and I installed Java 6 by downloading the rpm.bin from Sun and I installed maven2 using Add/Remove Software tool supplied by Fedora. The problem was that when I run mvn, I get the following error:

 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:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: org.codehaus.classworlds.Launcher.  Program will exit.


A search on the internet suggested other people had a similar problem which may or may not be solved by setting M2_HOME and/or JAVA_HOME correctly. For me, this didn't help. I worked out the problem by editing /usr/share/bin/mvn and seeing the command it was trying to run:

 exec "$JAVACMD" \
  $MAVEN_OPTS \
  -classpath "${M2_HOME}"/boot/classworlds*.jar \
  "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
  "-Dmaven.home=${M2_HOME}"  \
  ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS


From this I learned, that it was looking in /usr/share/maven/boot for a jar but this folder was empty on my system. Next, I used "locate classworlds.jar" to find out if this file existed and sure enough it did. In the end the solution was this:

 su - root
cd /usr/share/maven2/boot
ln -s /usr/share/java/classworlds.jar


And then maven worked perfectly.

341°/3417 人阅读/0 条评论 发表评论

登录 后发表评论