Maven build fails in Docker Container - spring-boot

I am trying to create a kind of pipeline to put my application online at AWS so I am running this docker-compose into a EC2.
The error occurs when I run docker-compose -f docker-compose-java.yml up
The error is:
Starting bookinghub ... done
Attaching to bookinghub
bookinghub | [INFO] Scanning for projects...
bookinghub | [INFO] ------------------------------------------------------------------------
bookinghub | [INFO] BUILD FAILURE
bookinghub | [INFO] ------------------------------------------------------------------------
bookinghub | [INFO] Total time: 0.141 s
bookinghub | [INFO] Finished at: 2022-11-23T22:22:23Z
bookinghub | [INFO] ------------------------------------------------------------------------
bookinghub | [ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
bookinghub | [ERROR]
bookinghub | [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
bookinghub | [ERROR] Re-run Maven using the -X switch to enable full debug logging.
bookinghub | [ERROR]
bookinghub | [ERROR] For more information about the errors and possible solutions, please read the following articles:
bookinghub | [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
bookinghub exited with code 1
Dockerfile:
FROM maven:3.8.6-openjdk-18 AS MAVEN_BUILD
RUN microdnf install git -y
RUN mkdir ~/.ssh
COPY id_rsa /root/.ssh/id_rsa
COPY known_hosts /etc/ssh/known_hosts
WORKDIR /root/.ssh/
RUN chmod 400 id_rsa
RUN ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
RUN mkdir ~/repositorio
WORKDIR /repositorio/
RUN git clone git#gitlab.com:booking_hub/grupo_04_bookinghub.git
RUN cd grupo_04_bookinghub/backend/APIrest/APIrest
RUN mvn clean install "-Dmaven.test.skip=true" && mvn package
FROM openjdk:17-slim
WORKDIR /app
COPY --from=MAVEN_BUILD /repositorio/target/APIrest-*.jar /app/APIrest.jar
ENTRYPOINT ["java","-Dspring.profiles.active=dev", "-jar", "APIrest.jar"]
docker-compose-java.yml
version: "3.7"
services:
#outro container --- backend
springweb:
container_name: bookinghub
build: . #preciso do Dockerfile para gerar a imagem
ports:
- "8080:8080"
networks:
- servers
environment:
SPRING_PROFILES_ACTIVE: dev
networks:
servers:
driver: bridge
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>br.com.APIrest</groupId>
<artifactId>APIrest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>APIrest</name>
<description>project for Spring Boot APIrest</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I expect to everytime I run docker-compose the container do a git clone, build the project and run the jar file.
#EDIT1:
Alright, so I thought the image was builded with the errors I came across before (which were a lot) and then it wasn't building the image from the scratch (so I think running docker-compose isn't building the image from dockerfile everytime I run the command).
I ran sudo docker system prune -a --volumes and ran docker-compose again so the error changed to a build failure which I expected since this instance is not connected to a MySql RDS or MySql container...
Now I will connect the DB to this EC2 and try to run again..
From now, born a new question: the image isn't building every time I run docker-compose, how could I force to re-build the image? My objective here is to when any changes occurs to the main branch of my project, I need to run only once docker-compose and then my backend will self update
#EDIT2:
Changed a couple of things at dockerfile
FROM maven:3.8.6-openjdk-18 AS MAVENBUILD
RUN microdnf install git -y
RUN mkdir ~/.ssh
COPY id_rsa /root/.ssh/id_rsa
COPY known_hosts /etc/ssh/known_hosts
WORKDIR /root/.ssh/
RUN chmod 400 id_rsa
RUN ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
RUN mkdir ~/repositorio
WORKDIR /repositorio/
RUN git clone git#gitlab.com:booking_hub/grupo_04_bookinghub.git
WORKDIR /repositorio/grupo_04_bookinghub/backend/APIrest/APIrest
RUN mvn clean install -Dmaven.test.skip=true && mvn package
FROM openjdk:17
WORKDIR /app
COPY --from=MAVENBUILD /repositorio/grupo_04_bookinghub/backend/APIrest/APIrest/target/APIrest-0.0.1-SNAPSHOT.jar /app/APIrest.jar
ENTRYPOINT ["java","-Dspring.profiles.active=dev", "-jar", "APIrest.jar"]
application now runs inside the docker container...
Problem solved! :)

Related

Jenkins maven test(selenium tests) command giving errors

I have created a maven project for selenium and it is executing fine when I run the command "mvn test" in command prompt.
I pushed it to a repository in GitHub and created a Jenkins job (Using Git plugin and Maven Integration Plugin).
When I run that job it is pulling the source code from GitHub to Jenkins Workspace but the job is failing. The following is the console output.
Started by user admin
Running as SYSTEM
Building in workspace C:\Users\HP\.jenkins\workspace\Automation Scripts After Build Job
The recommended git tool is: NONE
No credentials specified
> git.exe rev-parse --resolve-git-dir C:\Users\HP\.jenkins\workspace\Automation Scripts After Build Job\.git # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://github.com/subbustech/seleniumtraining # timeout=10
Fetching upstream changes from https://github.com/subbustech/seleniumtraining
> git.exe --version # timeout=10
> git --version # 'git version 2.38.1.windows.1'
> git.exe fetch --tags --force --progress -- https://github.com/subbustech/seleniumtraining +refs/heads/*:refs/remotes/origin/* # timeout=10
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
Checking out Revision 589e4dc1d99da6a581431416bff866524e5cbab8 (refs/remotes/origin/master)
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f 589e4dc1d99da6a581431416bff866524e5cbab8 # timeout=10
Commit message: "pushing new changes"
First time build. Skipping changelog.
Parsing POMs
Established TCP socket on 54429
[Automation Scripts After Build Job] $ "C:\Program Files\Java\jdk-17.0.5/bin/java" -cp C:\Users\HP\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-agent-1.14.jar;C:\maven\boot\plexus-classworlds-2.6.0.jar;C:\maven/conf/logging jenkins.maven3.agent.Maven35Main C:\maven C:\Users\HP\.jenkins\war\WEB-INF\lib\remoting-3044.vb_940a_a_e4f72e.jar C:\Users\HP\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-interceptor-1.14.jar C:\Users\HP\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.14.jar 54429
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\Users\HP\.jenkins\workspace\Automation Scripts After Build Job\pom.xml test
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< SeleniumTraining:SeleniumTraining >------------------
[INFO] Building SeleniumTraining 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SeleniumTraining ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\HP\.jenkins\workspace\Automation Scripts After Build Job\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) # SeleniumTraining ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 122 source files to C:\Users\HP\.jenkins\workspace\Automation Scripts After Build Job\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.010 s
[INFO] Finished at: 2022-11-10T23:30:54+05:30
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project SeleniumTraining: Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module #0x412a7bf9) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module #0x412a7bf9 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[JENKINS] Archiving C:\Users\HP\.jenkins\workspace\Automation Scripts After Build Job\pom.xml to SeleniumTraining/SeleniumTraining/0.0.1-SNAPSHOT/SeleniumTraining-0.0.1-SNAPSHOT.pom
channel stopped
Finished: FAILURE
But if I go to Jenkins workspace and open a command prompt and run the mvn test command it is working fine and running with out any issues.
The following is the pom.xml, I am using.
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SeleniumTraining</groupId>
<artifactId>SeleniumTraining</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.9</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng01.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
Can anyone help me with what's wrong here?
thank you.

Docker-compose - Non-resolvable parent POM: Could not find artifact

I have three pom.xml files, where one is the parent and the two others are the children. The parent is located in a folder named calculatorws and the two children are located separately in two folders(inside the folder calculatorws): calculatorws-calculator and calculatorws-rest and each one of them contains a pom.xml file.
The parent pom.xml file is:
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>calculatorws</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<modules>
<module>calculatorws-calculator</module>
<module>calculatorws-rest</module>
</modules>
The pom.xml file of calculatorws-rest is:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.company</groupId>
<artifactId>calculatorws</artifactId>
<version>0.0.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>calculatorws-rest</artifactId>
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
The pom.xml file of calculatorws-calculator is:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.company</groupId>
<artifactId>calculatorws</artifactId>
<version>0.0.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>calculatorws-calculator</artifactId>
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
I have three Dockerfiles respectively for the parent and the children.
The Dockerfile of the parent is:
FROM maven:3-jdk-8-alpine
COPY pom.xml /application/
WORKDIR /application/
COPY . /application/
RUN mvn clean package
The Dockerfile for calculatorws-rest is:
FROM maven:3-jdk-8-alpine as builder
COPY pom.xml /calculatorws-rest/
WORKDIR /calculatorws-rest/
COPY . /calculatorws-rest/
FROM openjdk:8-jre-alpine
COPY --from=builder /calculatorws-rest/target/calculatorws-rest-0.0.1.jar /rest.jar
EXPOSE 8080
CMD ["java", "-jar", "/rest.jar"]
The Dockerfile for calculatorws-calculator is:
FROM maven:3-jdk-8-alpine as builder
COPY pom.xml /calculatorws-calculator/
WORKDIR /calculatorws-calculator/
COPY . /calculatorws-calculator/
FROM openjdk:8-jre-alpine
COPY --from=builder /calculatorws-calculator/target/calculatorws-calculator-0.0.1.jar /calculator.jar
EXPOSE 8080
CMD ["java", "-jar", "/calculator.jar"]
I run the project using the docker-compose file as shown below:
version: '3.9'
services:
rabbitmq:
image: rabbitmq:3.7.3-alpine
container_name: rabbit
ports:
- 5672:5672
application:
build: .
calculatorws-rest:
build: ./calculatorws-rest
calculatorws-calculator:
build: ./calculatorws-calculator
I fixed the error with the non resolvable parent POM by deleting the RUN mvn clean package from the Dockerfile of calculatorws-rest, but now I get this error:
No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
I think I have a problem with my structure and I am not getting it.

Why "mvn deploy" command is rebuilding .jar?

I am working on the spring-boot java application. I am trying to build and publish .jar using maven with profile.but somehow mvn deploy command rebuilds .jar again.
option 1:I used mvn clear install -Pdev and did mvn deploy -Dmaven.install.skip=truewithout profile and its deploying default .jar file
option 2: I passed profile id during publish too.mvn deploy -Dmaven.install.skip=true ITs working fine but its rebuilding everything again and we do not want to use maven profile name again during mvn deploy
pom.xml
<project...>
...
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>dev</id>
<properties>
<spring.profile.id>dev</spring.profile.id>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>prod</id>
<properties>
<spring.profile.id>prod</spring.profile.id>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
mvn clean install -Pdev
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) # xyz-
profile
[INFO] Building jar: /sys_apps_01/jenkins/workspace/xyz-profile-0.0.3-
SNAPSHOT.jar
mvn deploy mvn deploy -Pdev
I am getting below logs for both deploy command:
[DEBUG] isUp2date: false (Destination /sys_apps_01/jenkins/workspace/xyz-
profile-0.0.3-SNAPSHOT.jar not found.)
[INFO] Building jar: /sys_apps_01/jenkins/workspace/xyz-profile-0.0.3-
SNAPSHOT.jar
Can anyone help me to understand,why its rebuilding again while deploy ?
You should read about Maven lifecycle for understand what is happening : https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
So when you're doing a deploy command maven trigger all previous goal in the lifecycle :
validate
compile
test
package
verify
install
Then deploy

Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>

Getting this error while building the sprint boot application through eclipse.
[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
but working fine if i build through command prompt.
Attaching the pom.xml below.
Pom.xml
<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>com.sarun</groupId>
<artifactId>SpringAngular</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name> SpringDataRestAngular</name>
<description>Spring + AngularJS </description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<!-- <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> -->
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1100-jdbc41</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>com.programmingfree.springservice.Application</start-class>
<java.version>1.7</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
If you are using debug configuration for maven, use the command
clean install
And skip all the tests.
Try without command mvn in the command line. Example:
From:
mvn clean install jetty:run
To:
clean install jetty:run
Thanks for the reply.
I was using "mvn clean install" in the maven build configuration.
we no need to use "mvn" command if running through eclipse.
After buiding the application using the command "clean install" , I got one more error -
"No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?"
I followed this link:-
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
now application building is fine in eclipse.
I was getting the same error. I was using Intellij IDEA and I wanted to run Spring boot application. So, solution from my side is as follow.
Go to Run menu -> Run configuration -> Click on Add button from the left panel and select maven -> In parameters add this text -> spring-boot:run
Now press Ok and Run.
You have to specify any one of the above phase to resolve the above error. In most of the situations, this would have occurred due to running the build from the eclipse environment.
instead of mvn clean package or mvn package you can try only package its work fine for me
I too got the similar problem and I did like below..
Rt click the project, navigate to Run As --> click 6 Maven Clean and your build will be success..
Sometimes this error comes because it's simply the wrong folder. :-(
It shall be the folder which contains the pom.xml.
Create new Maven file with path as classpath and goal as class name

Cannot download Maven Resources Plugin when building in Jenkins

I have created Selenium IDE test cases and have tested them in Eclipse. The project is a Maven java project and the tests will run fine in Eclipse however, when I add the project to Jenkins and try to build my project, there is a error and a build failure.
The error:
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Selenium IDE Recon
Parsing POMs
Discovered a new module Test:SeleniumTest SeleniumTest
Modules changed, recalculating dependency graph
[Selenium IDE Recon] $ C:\java/bin/java -cp "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-agent-1.5.jar;C:\Users\MC44948\Software\springsource\springsource\apache-maven-3.0.4\boot\plexus-classworlds-2.4.jar" org.jvnet.hudson.maven3.agent.Maven3Main C:\Users\MC44948\Software\springsource\springsource\apache-maven-3.0.4 "C:\Program Files (x86)\Jenkins\war\WEB-INF\lib\remoting-2.45.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-1.5.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar" 53032
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\Users\MC44948\Spring_Workspace\Selenium IDE Recon\pom.xml install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SeleniumTest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.671s
[INFO] Finished at: Mon Sep 29 11:46:35 BST 2014
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]
[JENKINS] Archiving C:\Users\MC44948\Spring_Workspace\Selenium IDE Recon\pom.xml to Test/SeleniumTest/0.0.1-SNAPSHOT/SeleniumTest-0.0.1-SNAPSHOT.pom
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
channel stopped
Finished: FAILURE
My pom:
<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>Test</groupId>
<artifactId>SeleniumTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SeleniumTest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.43.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.43.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>0.16</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
</project>
This seems to be related to Internet connectivity. Did you notice the error: "Unknown host repo.maven.apache.org"?
Try wget http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom and see if you can fetch data.
For more details, you can refer this link.
You can try also this...
My Java project was building successfully when building from command line, but I was getting an error "Unknown host repo.maven.apache.org" when building it with Jenkins.
The problem was is the custom maven settings file which our company was using.
So what you can do is: Under Job configuration, Build section, click "Advanced...".
Set the "Settings file" to "Settings file in filesystem" and give the path to the setting file from your maven installation location. For example
C:\Program Files\apache-maven-3.1.1\conf\settings.xml
Set the "Global Settings file" to "Global settings file on filesystem" and give the path to the "${user.home}/.m2/settings.xml".
You might be behind cooperate proxy (or any other proxy\firewall).
Make sure you can access maven central from the slave you're running your build.
If not - configure your http_proxy and https_proxy on your server.

Resources