问题
I have just installed new Maven into my new Fedora 17 64bit.
Details:
java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)
javac -version
javac 1.6.0_32
echo $JAVA_HOME
/usr/java/jdk1.6.0_32
echo $JRE_HOME
/usr/java/jdk1.6.0_32/jre
echo $M2_HOME
/usr/local/maven/apache-maven-3.0.4
echo $M2
/usr/local/maven/apache-maven-3.0.4/bin
echo $PATH
/usr/local/maven/apache-maven-3.0.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/usr/sbin:/usr/java/jdk1.6.0_32/bin:/home/bujaka/.local/bin:/home/bujaka/bin
which mvn
/usr/local/maven/apache-maven-3.0.4/bin/mvn
But mvn -version throws java.lang.ClassNotFoundException.
java.lang.ClassNotFoundException: org.apache.maven.cli.MavenCli
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:145)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:267)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
P.S. I installed maven from apache site (not from fedora repos)
回答1:
MavenCli class is in maven-embedder. Are you behind a proxy?
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.somewhere.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
</proxy>
</proxies>
...
</settings>
@See Maven Proxy Settings
回答2:
thanks user1436170
, your last comment did the job for me as well:
/lib catalog was empty in maven.tar.gz archive.
When opening via krusader, lib folder in tar.gz file it was empty, but it contains jars when opening via ark.
Anyway zip works.
回答3:
I just came across this same issue. Bujaka's comment and Peter Butkovic's answer get at the issue, but for the record here's my take on it and the solution I used.
I don't know what causes this, but sometimes the entire content of the /lib folder in your maven installation directory can become empty. This may be the case when you get this error.
If you check your /lib folder and find that it is not empty, it is still possible (although unlikely) that a crucial file somehow got deleted.
If your maven installation used to work find and only started acting up recently, then the zipped archive you used was probably fine. Here's what to do:
- Rename your installation directory (or if you're brave, just delete it).
- Get the original zipped archive. (If you're like me, it's still somewhere in your increasingly cluttered downloads folder. If not you'll have to re-download it.)
- Unzip said archive into the location of your original installation directory (which you either renamed or deleted).
Your maven installation should now work again.
来源:https://stackoverflow.com/questions/10889445/maven-mvn-version-java-lang-classnotfoundexception