詹金斯的Maven构建失败了

时间:2017-05-07 12:38:01

标签: java spring maven jenkins payara

我想要使用Jenkins在Payara服务器上部署Maven项目。有两个项目:域项目和Spring Web MVC项目。 Spring项目配置为在域项目之后构建,因为它依赖于域项目。

每次我提交项目时,都会触发构建。但是,我总是收到以下错误:无法解析POM。请参阅下面的完整控制台输出。

这是我第一次使用Payara和Jenkins,我无法真正理解我做错的事情......任何帮助或指导正确的方向都会非常感激:)

控制台输出

Started by GitHub push by WouterCypers
Building in workspace /root/.jenkins/workspace/bookstore domain
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/ucll-ip/project-ip-WouterCypers.git # timeout=10
Fetching upstream changes from https://github.com/ucll-ip/project-ip-WouterCypers.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://github.com/ucll-ip/project-ip-WouterCypers.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 5dec7ef129e3aa4f142e0ffd41579c741aab86be (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 5dec7ef129e3aa4f142e0ffd41579c741aab86be
 > git rev-list a3f63a2901948bc6f55e3f2bcdeca5daebc1ea08 # timeout=10
Parsing POMs
Established TCP socket on 54633
[bookstore-domain] $ /usr/lib/jvm/jdk1.8.0_131/bin/java -cp /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.8.1.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.5.2.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging jenkins.maven3.agent.Maven33Main /root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven /opt/payara41/glassfish/domains/domain1/applications/jenkins/WEB-INF/lib/remoting-3.4.1.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.8.1.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.8.1.jar 54633
<===[JENKINS REMOTING CAPACITY]===>���channel started
Executing Maven:  -B -f /root/.jenkins/workspace/bookstore domain/bookstore-domain/pom.xml clean install -DskipTests
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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$2.run(Request.java:336)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
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
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$2.run(Request.java:336)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
    at ......remote call to Channel to Maven [/usr/lib/jvm/jdk1.8.0_131/bin/java, -cp, /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.8.1.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.5.2.jar:/root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging, jenkins.maven3.agent.Maven33Main, /root/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven, /opt/payara41/glassfish/domains/domain1/applications/jenkins/WEB-INF/lib/remoting-3.4.1.jar, /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.8.1.jar, /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.8.1.jar, 54633](Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1537)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
    at hudson.remoting.Channel.call(Channel.java:822)
    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:404)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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$2.run(Request.java:336)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
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:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: FAILURE

Spring项目的POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.ucll</groupId>
    <artifactId>bookstore-springmvc</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>bookstore-springmvc</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <jstl.version>1.2</jstl.version>
        <java.version>1.8</java.version>
        <javaee.version>7.0</javaee.version>
        <maven.war.version>2.3</maven.war.version>
        <spring.version>4.3.6.RELEASE</spring.version>
        <spring.security.version>4.2.2.RELEASE</spring.security.version>
        <payara.home>/c/Program Files/payara41</payara.home>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.ucll</groupId>
            <artifactId>bookstore-domain</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!-- FRAMEWORK ETC -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>${javaee.version}</version>
            <!-- provided indicates that we do need this dependency for compilation and test, but not at runtime -->
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- SPRING SECURITY -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${spring.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${spring.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${spring.security.version}</version>           
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>${maven.war.version}</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.glassfish.maven.plugin</groupId>
                <artifactId>maven-glassfish-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <glassfishDirectory>${payara.home}/glassfish</glassfishDirectory>
                    <user>admin</user>
                    <passwordFile>${payara.home}/glassfish/config/password.txt</passwordFile>
                    <debug>true</debug>
                    <terse>false</terse>
                    <echo>true</echo>
                    <domain>
                        <name>domain1</name>
                        <adminPort>4848</adminPort>
                        <httpPort>8080</httpPort>
                    </domain>
                    <components>
                        <component>
                            <name>${project.artifactId}</name>
                            <artifact>target/${project.build.finalName}.war</artifact>
                        </component>
                    </components>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

域项目的POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.ucll</groupId>
    <artifactId>bookstore-domain</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <java.version>1.8</java.version>
        <junit.version>4.12</junit.version>
        <jgiven.version>0.12.1</jgiven.version>
        <maven.surefire.version>2.19</maven.surefire.version>
        <persistence.version>2.6.4</persistence.version>
        <derbyclient.version>10.13.1.1</derbyclient.version>
        <spring.security.version>4.2.2.RELEASE</spring.security.version>
        <hibernate.version>5.4.1.Final</hibernate.version>
        <glassfish.javax.el.version>3.0.1-b08</glassfish.javax.el.version>
        <spring.context.version>4.3.6.RELEASE</spring.context.version>
        <jgiven.version>0.12.1</jgiven.version>
        <maven.surefire.version>2.19</maven.surefire.version>        
    </properties>

    <dependencies>

        <!-- TESTING -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>
        <dependency>
            <groupId>com.tngtech.jgiven</groupId>
            <artifactId>jgiven-junit</artifactId>
            <version>${jgiven.version}</version>
        </dependency>

        <!-- JPA -->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.jpa</artifactId>
            <version>${persistence.version}</version>
        </dependency>

        <!-- DERBY DB -->
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derbyclient</artifactId>
            <version>${derbyclient.version}</version>
        </dependency>        

        <!-- BEAN VALIDATION -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator-cdi</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.el</artifactId>
            <version>${glassfish.javax.el.version}</version>
        </dependency>

        <!-- SPRING CONTEXT -->
        <!-- used in Author.java for validation of the Date format -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.context.version}</version>
            <type>jar</type>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
                <version>${maven.surefire.version}</version>
            </plugin>
            <plugin>
                <groupId>com.tngtech.jgiven</groupId>
                <artifactId>jgiven-maven-plugin</artifactId>
                <version>${jgiven.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <format>html</format>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

1 个答案:

答案 0 :(得分:2)

这似乎是詹金斯的一个问题,已经在这里回答:Getting exception while configuring the maven project in jenkins

我的解决方案是将更改设置为构建配置:

配置&gt;构建&gt;高级

  • Settings file设置为Settings file in filesystem,然后输入设置文件的路径。就我而言:/root/.m2/settings.xml
  • Global Settings file设置为Global settings file on filesystem,然后输入全局设置文件的路径。我没有(我认为)所以我只是将它设置为/root/.m2/settings.xml

这应该可以解决问题。现在我只需解决其他十几个构建错误:)