ERROR:Some problems were encountered while processing the POMs: - java

I am trying to run this source code where I get from https://github.com/kishancs2020/TicketBookingServiceJunitTesting Github in my Jenkins to see the pipeline that has created in Jenkinsfile of the source code.
I already update maven, java version as to fix it but still the error is same. I also has go through this link http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException but can't find the solution. Any suggestion to fix this error.
+ mvn clean -f TicketBookingServiceJunitTesting
POM file TicketBookingServiceJunitTesting specified with the -f/--file command line argument does not exist
[[1;34mINFO[m] Scanning for projects...
[[1;31mERROR[m] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-readable POM /var/lib/jenkins/workspace/ervicejunittesting-master_master/TicketBookingServiceJunitTesting: /var/lib/jenkins/workspace/ervicejunittesting-master_master/TicketBookingServiceJunitTesting (No such file or directory) #
#
[[1;31mERROR[m] The build could not read 1 project -> [1m[Help 1][m
[[1;31mERROR[m]
[[1;31mERROR[m] The project (/var/lib/jenkins/workspace/ervicejunittesting-master_master/TicketBookingServiceJunitTesting) has 1 error
[[1;31mERROR[m] Non-readable POM /var/lib/jenkins/workspace/ervicejunittesting-master_master/TicketBookingServiceJunitTesting: /var/lib/jenkins/workspace/ervicejunittesting-master_master/TicketBookingServiceJunitTesting (No such file or directory)
[[1;31mERROR[m]
[[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
[[1;31mERROR[m] Re-run Maven using the [1m-X[m switch to enable full debug logging.
[[1;31mERROR[m]
[[1;31mERROR[m] For more information about the errors and possible solutions, please read the following articles:
[[1;31mERROR[m] [1m[Help 1][m http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
This is the pom.xml file
<?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>com.infotech.book.ticket.app</groupId>
<artifactId>TicketBookingRestApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TicketBookingRestApp</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</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-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-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>
May I know why it says pom.xml is not readable?. The pipeline only success at git repo & clean stage only.

-f flag in maven is used to specify the pom file other than pom.xml file in current folder that's the reason you are getting the exception.
If you want to test a particular test class -Dtest switch to specify the test class
REF: https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

Related

Error with "mvn spring-boot:run", [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile

I'm trying to use the command mvn spring-boot:run or when i try to use the command mvn clen install. But it's giving me this kind of error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 17 -> [Help 1]
[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
This is my pom file:
<?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.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>qualabs</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
if i run the project using the main method in the application it's runnig perfectly.
I don't know if this a problem of dependencies
Thanks for the help guys
Try to execute the following command to check which Java version is used by default on your computer:
java -version
If it differs from the 17 version, which you're trying to use in your project, you should update your JAVA_HOME variable.
You can use this command to list all available Java versions, installed on your computer:
/usr/libexec/java_home -V
Example output from my machine:
17.0.2 (arm64) "Oracle Corporation" - "OpenJDK 17.0.2" /Users/golovnya/Library/Java/JavaVirtualMachines/openjdk-17.0.2/Contents/Home
11.0.14.1 (x86_64) "Amazon.com Inc." - "Amazon Corretto 11" /Users/golovnya/Library/Java/JavaVirtualMachines/corretto-11.0.14.1/Contents/Home
Such command may be used for setting a specific Java version as the default one (17 in this example):
export JAVA_HOME=$(/usr/libexec/java_home -v 17)

Java Maven Spring Could not transfer artifact org.apache.maven.surefire:surefire-junit-platform:pom:2.22.2 from/to central

Java Spring project fails to package the project with maven, printing the following error:
Could not transfer artifact org.apache.maven.surefire:surefire-junit-platform:pom:2.22.2 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom
The use used pom:
<?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.6.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>***</groupId>
<artifactId>***</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>***</name>
<description>***</description>
<properties>
<java.version>1.8</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-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-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 use IntelliJ to develop and build the project.
I do not need a proxy to enter the internet. If I click the link, I can see the pom file without problems. Reloading the project does not work, downloading all sources neither.
In the local storage, I find the following files:
C:\Users\***\.m2\repository\org\apache\maven\plugins\maven-surefire-plugin\2.22.2
_remote.repositories
maven-surefire-plugin-2.22.2.jar
maven-surefire-plugin-2.22.2.jar.sha1
maven-surefire-plugin-2.22.2.pom
maven-surefire-plugin-2.22.2.pom.sha1
Removing them and reloading the project restores the files, the error persists.
I cleaned the project and used the -Dhttps.protocols=TLSv1.2 parameter no changes.
Edit:
Using a VPN doe not work.
Output of mvn -v:
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Program Files\java\apache-maven-3.8.4
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Program Files\Eclipse Adoptium\jdk-8.0.312.7-hotspot\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
When building with mvn clean package -U:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project Grafnus-Server: Unable to generate classpath: org.apache.maven.artifact.resolver.ArtifactResolutionException: Unable to get dependency information for org.apache.maven.surefire:surefire-junit-platform:jar:2.22.2: Failed to retrieve POM for org.apache.maven.surefire:surefire-junit-platform:jar:2.22.2: Could not transfer artifact org.apache.maven.surefire:surefire-junit-platform:pom:2.22.2 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom
[ERROR] from the specified remote repositories:
[ERROR] central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false)
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0
The issue was the outdated java version. I updated to a newer one and at first I did not change it in the project settings (thought that would change on his own). Now it works like a charm. Thanks to #khmarbaise

hamcrest-core: jar:1.4-atlassian-1 could not be resolved on MVN clean install on Spring Boot project

Here is my pom
<?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.3.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.mailer</groupId>
<artifactId>portfolio</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>portfolio</name>
<description>portfolio services</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.mailjet</groupId>
<artifactId>mailjet-client</artifactId>
<version>4.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Build logs:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.mailer:portfolio >------------------------
[INFO] Building portfolio 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
.
.
.
[WARNING] The POM for org.hamcrest:hamcrest-core:jar:1.4-atlassian-1 is missing, no dependency information available
.
.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project portfolio: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.22.2 or one of its dependencies could not be resolved: Failure to find org.hamcrest:hamcrest-core:jar:1.4-atlassian-1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [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/PluginResolutionException
**
Any idea why am getting this error related to hamcrest jar? I added the same version of the jar in .m2/repo/... but I still get the same error. Any idea which dependency in this POM is using it internally? Do I have to change any version?
Command used to build
mvn clean install
If I run this project as Spring Boot app then the service is up but what I need is a jar out of this to host in a cloud.
This was the issue with my local repository. I had to point to a new repo location under .m2 in settings.xml.

How to fix module not found: spring.web and similar errors

I'm trying to build a simple maven spring-rest app with Java 11, but I'm getting 'module not found error' constantly.
I read a lot of similar questions on SO. I tried various recommendations - deletions of maven repository, resolving some warnings etc., but I still can't make the project work.
My parrent 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>com.luv2code</groupId>
<artifactId>spring-rest-demo</artifactId>
<version>1.0</version>
<modules>
<module>nedim</module>
</modules>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<!-- Add Spring MVC and REST support -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.5.RELEASE</version>
</dependency>
<!-- Add Jackson for JSON converters -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
<!-- Add Servlet support for
Spring's AbstractAnnotationConfigDispatcherServletInitializer -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<!-- Support for Maven WAR Plugin -->
<build>
<finalName>spring-rest-demo</finalName>
<pluginManagement>
<plugins><plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Child pom:
<?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">
<parent>
<artifactId>spring-rest-demo</artifactId>
<groupId>com.luv2code</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nedim</artifactId>
</project>
module-info.java:
open module nedim {
requires spring.context;
requires spring.webmvc;
requires spring.web;
}
When I run maven clean install, I get the following:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project nedim: Compilation failure: Compilation failure:
[ERROR] /D:/Workspace/Java/spring-rest-demo/nedim/src/main/java/module-info.java:[2,24] module not found: spring.context
[ERROR] /D:/Workspace/Java/spring-rest-demo/nedim/src/main/java/module-info.java:[3,24] module not found: spring.webmvc
[ERROR] /D:/Workspace/Java/spring-rest-demo/nedim/src/main/java/module-info.java:[4,24] module not found: spring.web
[ERROR] -> [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/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :nedim
Also, I added to VM options --show-module-resolution and there is no spring modules on list
The main problem is: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile. This is a very old version that doesn't support JPMS. Please update to 3.8.1

`mvn package` giving Fatal error compiling: invalid flag: -parameters error

I've generated a spring boot project using the Initialzr tool. I've following allow this tutorial to the point where I've added a template and controller:
https://www.baeldung.com/spring-boot-start
Now I'm just trying to run mvn clean package but just seeing the following error in my command prompt:
...
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.501 s
[INFO] Finished at: 2019-06-17T11:03:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project myapp: Fatal error compiling: invalid flag: -parameters -> [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
I've tried Googling some of the errors here as usually I can fix the issues but not really anything too informative here for me to grasp.
Below is my pom.xml file too encase there lies the problem:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>My App</name>
<properties>
<java.version>1.8</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-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
For me, the problem was that maven was using a different version of Java than the project.
After I changed it so that both maven and project are using the same versions of Java, everything worked fine.
The discrepancy in my case was that the project was on java 1.8 and maven was using java 1.7.
I changed the maven version of java directly since I needed to have an older version of Java set in Java Home. For that, I referred to this topic: How to set specific java version to Maven
I hope that this helps.
In my case I did this:
In pom.xml added the following lines:
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Go to the properties of the proyect -> Java Build Path -> Libraries
Checked that the "JRE System Library[]" was using "JavaSE-1.8 (jre1.8.0_221) as JRE.
Selected "JRE System Library" -> Click on "Edit..."
Ticked the option "Alternate JRE:" and selected "jdk1.8.0_221".
Saved everything, executed "Maven Clean" in the project and Installed Maven in the project.
After Eclipse downloaded the repositories of Maven, the build was successful.

Categories