我有一个运行测试的项目。这是一个使用Selenium的maven项目。它在本地启动时运行正常,但是从Hudson平台,它会抛出NoClassDefFoundError:
Parsing POMs
[elsevier-selenium] $ "C:\Program Files\Java\jdk1.7.0_25/bin/java" -Xmx1024m -cp E:\hudson\plugins\maven-plugin\WEB-INF\lib\maven-agent-1.353.jar;E:\maven\boot\classworlds-1.1.jar hudson.maven.agent.Main E:\maven E:\hudson\war\WEB-INF\lib\remoting-1.353.jar E:\hudson\plugins\maven-plugin\WEB-INF\lib\maven-interceptor-1.353.jar 1753 E:\hudson\plugins\maven-plugin\WEB-INF\lib\maven2.1-interceptor-1.2.jar
<===[HUDSON REMOTING CAPACITY]===>channel started
Executing Maven: -B -f E:\hudson\jobs\tests-selenium\workspace\elsevier-selenium\pom.xml integration-test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building selenium-elsevier
[INFO] task-segment: [integration-test]
[INFO] ------------------------------------------------------------------------
[INFO] [compiler:testCompile {execution: default}]
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to E:\hudson\jobs\tests-selenium\workspace\elsevier-selenium\target\test-classes
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [failsafe:integration-test {execution: default}]
[INFO] Failsafe report directory: E:\hudson\jobs\tests-selenium\workspace\elsevier-selenium\target\failsafe-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running fr.elsevier.tests.disponibilite.SearchTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.203 sec <<< FAILURE!
fr.elsevier.tests.disponibilite.SearchTest Time elapsed: 0.203 sec <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class fr.elsevier.tests.BaseSelenium
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.apache.maven.surefire.report.SmartStackTraceParser.getClass(SmartStackTraceParser.java:63)
at org.apache.maven.surefire.report.SmartStackTraceParser.<init>(SmartStackTraceParser.java:53)
at org.apache.maven.surefire.common.junit4.JUnit4StackTraceWriter.smartTrimmedStackTrace(JUnit4StackTraceWriter.java:72)
[...]
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
SearchTest扩展了BaseSelenium。
这意味着它甚至无法在我的源文件夹中找到一个类。项目结构如下:
src/
fr.elsevier.tests/
disponibilite/
SearchTest.java
BaseSelenium.java
pom.xml
为什么构建会生成这些NoClassDefFoundErrors以及如何修复它?
答案 0 :(得分:2)
尝试在local和hudson构建中使用-e或-X命令行参数。然后尝试比较启动的java进程的类路径。
然后,您可以实际找出maven生命周期的哪个部分通过更好的堆栈跟踪抛出异常。