码迷,mamicode.com
首页 > 其他好文 > 详细

错误: 找不到或无法加载主类 org.codehaus.plexus.classworlds.launcher.Launcher 问题排查

时间:2016-04-09 01:45:33      阅读:5008      评论:0      收藏:0      [点我收藏+]

标签:maven org.codehaus.plexus.classworlds.launcher.launcher mac brew

1. mac 下面是用homebrew 安装maven,安装成功,设置完M2_HOME ,使用mvn -version进行检测

houenxundeMacBook-Pro:3.3.9 houenxun$ mvn -version
错误: 找不到或无法加载主类 org.codehaus.plexus.classworlds.launcher.Launcher

2. 网上看了一堆解决方案,不明所以,于是自己尝试解决,首先,先定位一下问题的脚本

houenxundeMacBook-Pro:3.3.9 houenxun$ which mvn
/usr/local/bin/mvn
houenxundeMacBook-Pro:3.3.9 houenxun$ ls -l /usr/local/bin/mvn
lrwxr-xr-x  1 houenxun  admin  29  4  7 15:52 /usr/local/bin/mvn -> ../Cellar/maven/3.3.9/bin/mvn

打开mvn文件

#!/bin/bash
JAVA_HOME="${JAVA_HOME:-$(/usr/libexec/java_home)}" exec "/usr/local/Cellar/maven/3.3.9/libexec/bin/mvn" "$@"

可以看到真正调用的是

/usr/local/Cellar/maven/3.3.9/libexec/bin/mvn

打开该文件,文件比较长,定位到最后报错的地方

exec "$JAVACMD"   $MAVEN_OPTS   $MAVEN_DEBUG_OPTS   -classpath "${M2_HOME}"/boot/plexus-classworlds-*.jar   "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf"   "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}"   ${CLASSWORLDS_LAUNCHER} "$@"

使用echo打印真正的语句

exec /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java -classpath /usr/local/Cellar/maven/3.3.9/boot/plexus-classworlds-*.jar -Dclassworlds.conf=/usr/local/Cellar/maven/3.3.9/bin/m2.conf -Dmaven.home=/usr/local/Cellar/maven/3.3.9 -Dmaven.multiModuleProjectDirectory=/usr/local/Cellar/maven/3.3.9/libexec/bin org.codehaus.plexus.classworlds.launcher.Launcher

3. 很奇怪,在/usr/local/Cellar/maven/3.3.9目录下boot和bin都是不存在的,而却存在/usr/local/Cellar/maven/3.3.9/libexec目录下

houenxundeMacBook-Pro:3.3.9 houenxun$ pwd
/usr/local/Cellar/maven/3.3.9
houenxundeMacBook-Pro:3.3.9 houenxun$ ls
INSTALL_RECEIPT.json	NOTICE			bin
LICENSE			README.txt		libexec
houenxundeMacBook-Pro:3.3.9 houenxun$
houenxundeMacBook-Pro:3.3.9 houenxun$ cd libexec/
houenxundeMacBook-Pro:libexec houenxun$ ls
bin	boot	conf	lib
houenxundeMacBook-Pro:libexec houenxun$

4. 尝试将他们拷贝出去,的确OK了

houenxundeMacBook-Pro:3.3.9 houenxun$ mvn -version
exec /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java -classpath /usr/local/Cellar/maven/3.3.9/boot/plexus-classworlds-2.5.2.jar -Dclassworlds.conf=/usr/local/Cellar/maven/3.3.9/bin/m2.conf -Dmaven.home=/usr/local/Cellar/maven/3.3.9 -Dmaven.multiModuleProjectDirectory=/usr/local/Cellar/maven/3.3.9 org.codehaus.plexus.classworlds.launcher.Launcher -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/Cellar/maven/3.3.9
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.4", arch: "x86_64", family: "mac"

5. 问题似乎解决了,但不禁奇怪,难道homebrew安装maven有bug???


错误: 找不到或无法加载主类 org.codehaus.plexus.classworlds.launcher.Launcher 问题排查

标签:maven org.codehaus.plexus.classworlds.launcher.launcher mac brew

原文地址:http://houenxun.blog.51cto.com/3958763/1761956

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!