java 在 jenkins 中配置 maven 项目时出现异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43555981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting exception while configuring the maven project in jenkins
提问by sougata das
Not able to trigger a successful build using Jenkin.
无法使用 Jenkins 触发成功构建。
Jenkin Version : 2.46.1
Maven Version :3.5.0
Java version : jdk1.7.0_67
I created one simple project in java on Maven . Now when i integrate this with Jenkin and click on the build now.
Build is failed and getting some exception.
我在 Maven 上用 java 创建了一个简单的项目。现在,当我将其与 Jenkins 集成并立即单击构建时。
构建失败并出现异常。
java.lang.reflect.InvocationTargetException
I have attached the logs detail.
我附上了日志详细信息。
Log Detail:
日志详情:
Started by user sougata das Building in workspace C:\Users\sougatadas\workspace\TestNGTutorial Parsing POMs Established TCP socket on 50831 [TestNGTutorial] $ "C:\Program Files\Java\jdk1.7.0_67/bin/java" -cp "C:\Users\sougatadas\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven33-agent-1.8.1.jar;F:\apache-maven-3.5.0-bin\apache-maven-3.5.0\boot\plexus-classworlds-2.5.2.jar;F:\apache-maven-3.5.0-bin\apache-maven-3.5.0/conf/logging" jenkins.maven3.agent.Maven33Main
F:\apache-maven-3.5.0-bin\apache-maven-3.5.0 "C:\Users\sougata
das\.jenkins\war\WEB-INF\lib\remoting-3.7.jar" "C:\Users\sougata
das\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven33-interceptor-1.8.1.jar"
"C:\Users\sougata
das\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.8.1.jar"
50831 <===[JENKINS REMOTING CAPACITY]===>channel started Executing
Maven: -B -f C:\Users\sougata das\workspace\TestNGTutorial\pom.xml
install java.lang.reflect.InvocationTargetException at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven33Main.launch(Maven33Main.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
hudson.maven.Maven3Builder.call(Maven3Builder.java:139) at
hudson.maven.Maven3Builder.call(Maven3Builder.java:70) at
hudson.remoting.UserRequest.perform(UserRequest.java:153) at
hudson.remoting.UserRequest.perform(UserRequest.java:50) at
hudson.remoting.Request.run(Request.java:336) at
hudson.remoting.InterceptingExecutorService.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:262) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.lang.NoSuchFieldError: DEFAULT_USER_SETTINGS_FILE at
org.apache.maven.cli.DefaultMavenExecutionRequestBuilder.settings(DefaultMavenExecutionRequestBuilder.java:658)
at
org.apache.maven.cli.DefaultMavenExecutionRequestBuilder.getMavenExecutionRequest(DefaultMavenExecutionRequestBuilder.java:149)
at
org.jvnet.hudson.maven3.launcher.Maven33Launcher.getMavenExecutionRequest(Maven33Launcher.java:150)
at
org.jvnet.hudson.maven3.launcher.Maven33Launcher.main(Maven33Launcher.java:127)
... 21 more ERROR: Failed to parse POMs java.io.IOException:
java.lang.reflect.InvocationTargetException at
hudson.maven.Maven3Builder.call(Maven3Builder.java:179) at
hudson.maven.Maven3Builder.call(Maven3Builder.java:70) at
hudson.remoting.UserRequest.perform(UserRequest.java:153) at
hudson.remoting.UserRequest.perform(UserRequest.java:50) at
hudson.remoting.Request.run(Request.java:336) at
hudson.remoting.InterceptingExecutorService.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:262) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745) at ......remote call to
Channel to Maven [C:\Program Files\Java\jdk1.7.0_67/bin/java, -cp,
C:\Users\sougata
das\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven33-agent-1.8.1.jar;F:\apache-maven-3.5.0-bin\apache-maven-3.5.0\boot\plexus-classworlds-2.5.2.jar;F:\apache-maven-3.5.0-bin\apache-maven-3.5.0/conf/logging, jenkins.maven3.agent.Maven33Main,
F:\apache-maven-3.5.0-bin\apache-maven-3.5.0, C:\Users\sougata
das\.jenkins\war\WEB-INF\lib\remoting-3.7.jar, C:\Users\sougata
das\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven33-interceptor-1.8.1.jar,
C:\Users\sougata
das\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.8.1.jar,
50831](Native Method) at
hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:253) at
hudson.remoting.Channel.call(Channel.java:830) at
hudson.maven.ProcessCache$MavenProcess.call(ProcessCache.java:161)
at
hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:873)
at
hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1728) at
hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:544)
at
hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:405) Caused by:
java.lang.reflect.InvocationTargetException at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
hudson.maven.Maven3Builder.call(Maven3Builder.java:139) at
hudson.maven.Maven3Builder.call(Maven3Builder.java:70) at
hudson.remoting.UserRequest.perform(UserRequest.java:153) at
hudson.remoting.UserRequest.perform(UserRequest.java:50) at
hudson.remoting.Request.run(Request.java:336) at
hudson.remoting.InterceptingExecutorService.call(InterceptingExecutorService.java:68)
at java.util.concurrent.FutureTask.run(FutureTask.java:262) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.lang.Exception: java.lang.reflect.InvocationTargetException at
jenkins.maven3.agent.Maven33Main.launch(Maven33Main.java:179) ...
14 more Caused by: java.lang.reflect.InvocationTargetException at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven33Main.launch(Maven33Main.java:176)
... 14 more Caused by: java.lang.NoSuchFieldError:
DEFAULT_USER_SETTINGS_FILE at
org.apache.maven.cli.DefaultMavenExecutionRequestBuilder.settings(DefaultMavenExecutionRequestBuilder.java:658)
at
org.apache.maven.cli.DefaultMavenExecutionRequestBuilder.getMavenExecutionRequest(DefaultMavenExecutionRequestBuilder.java:149)
at
org.jvnet.hudson.maven3.launcher.Maven33Launcher.getMavenExecutionRequest(Maven33Launcher.java:150)
at
org.jvnet.hudson.maven3.launcher.Maven33Launcher.main(Maven33Launcher.java:127)
... 21 more channel stopped Finished: FAILURE
回答by VonC
The message error Caused by: java.lang.NoSuchFieldError: DEFAULT_USER_SETTINGS_FILE
is followed by issue JENKINS-43446, fixed in Jenkins Maven plugin, Version 2.16 (June 08, 2017).
消息错误Caused by: java.lang.NoSuchFieldError: DEFAULT_USER_SETTINGS_FILE
后跟问题JENKINS-43446,固定在詹金斯Maven插件,版本2.16(2017年06月08日)。
That ticket includes the following comment:
该票包括以下评论:
I had to simply specify both a user and global settings file in the "Advanced" portion of the "Build" section. If I left either of these settings in the default configuration I would get these errors.
我必须在“构建”部分的“高级”部分中简单地指定用户和全局设置文件。如果我将这些设置中的任何一个保留在默认配置中,我都会收到这些错误。
As pointed out by mirabilosin the commentsand detailed by Wouter C's answer:
正如mirabilos在评论中指出的那样,Wouter C的回答有详细说明:
My solution was to set the change the build configuration:
In
Configure > Build > Advanced
:
- Set
Settings file
toSettings file in filesystem
and enter the path to your settings file. In my case:/root/.m2/settings.xml
- Set
Global Settings file
toGlobal settings file on filesystem
and enter the path to your global settings file.
I don't have one (I think) so I just set it to/root/.m2/settings.xml
also.
我的解决方案是设置更改构建配置:
在
Configure > Build > Advanced
:
- 设置
Settings file
为Settings file in filesystem
并输入设置文件的路径。就我而言:/root/.m2/settings.xml
- 设置
Global Settings file
为Global settings file on filesystem
并输入全局设置文件的路径。
我没有(我认为),所以我也将其设置为/root/.m2/settings.xml
。
回答by user3297199
Try using a version 3.3.9 of Maven on Jenkins.
尝试在 Jenkins 上使用 Maven 3.3.9 版。
See the bug https://issues.jenkins-ci.org/browse/JENKINS-43446
回答by Zeinab Abbasimazar
I have Jenkins version 2.60.3. I wanted to use Maven 3.5.0 and got the exact error.
我有 Jenkins 版本 2.60.3。我想使用 Maven 3.5.0 并得到了确切的错误。
My solution was to upgrade Maven Integration Plugin to 3.1.2.
我的解决方案是将 Maven 集成插件升级到 3.1.2。