Ant Ant Exception in thread "main" java.lang.NoClassDefFoundError

scmroad · 发布于 2012年12月06日 · 202 次阅读
96

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

Ant中调用mvn 出错 Ant test.xml 文件[code]

[/code]出错如下:[code] [cm@scmroad test]# ant -f test.xml

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

BUILD SUCCESSFUL Total time: 0 seconds [cm@scmroad test]# [/code]但是实际上,如果直接到${basedir}/../test 这个目录下,执行 mvn clean package 是能成功执行,没有任何

共收到 3 条回复
96
scmroad · #1 · 2012年12月06日

机器是64-bit CentOS

96
rexuekonglong · #2 · 2012年12月07日

那mvn clean package 写成一行 value 会执行吗?

4
laofo · #3 · 2012年12月07日

实际上就是没有设置好 M2_HOME

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.

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册