Maven: Failed to read artifact descriptor error - java

I cloned a JAVA repo and when I tried to build it with "mvn install", I got the following error
Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.3.2.RELEASE from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.3.2.RELEASE/spring-boot-starter-parent-2.3.2.RELEASE.pom and 'parent.relativePath' points at no local POM # line 6, column 13: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 2]
the repo "https://repo.maven.apache.org/maven2" is accessible in my browser when I open it in Chrome.
After some googling, I put a settings.xml file in the .m2 folder looks like this
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>securecentral</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>securecentral</id>
<!--Override the repository (and pluginRepository) "central" from the
Maven Super POM -->
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
Now when I run "mvn install", the error for spring-boot goes away. But I am facing this error now:
Failed to read artifact descriptor for org.apache.camel.springboot:camel-salesforce-starter:jar:3.4.2: Could not transfer artifact io.dropwizard.metrics:metrics-bom:pom:4.1.9 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/io/dropwizard/metrics/metrics-bom/4.1.9/metrics-bom-4.1.9.pom: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
My question is, why do I need to manually add and in settings.xml and why I am still getting the error for camel? Thanks

You can try to run mvn -U clean install
-U according to Maven CLI options is for
Forces a check for missing releases and updated snapshots on remote
repositories
or try to delete the local repository folder. Sometimes it gets messed up when having network problems...
You can find your local repo folder in your .m2 folder (on windows: C:\Users<your_username>.m2)
You can delete the whole repository folder or just some part of it. After that just run the mvn clean install

PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
Almost certain that root CA certificates on your system are outdated.
Try to update your JDK installation. Note that CA certificate used by your browser might not be same as JRE/JDK is using.
Without knowing more details about your system, it's hard to provide more accurate answer.
This answer provides possible workaround.

OK...got it working.
#rkosegi's answer put me on the right path. The root CA cert used by my browser is different than the one jdk uses. That's why I can view the repo in browser with no error but maven cannot access the repo.
Somehow my company (a financial institution) has a root CA cert overriding all the other root CA cert, that means, when I open any website (for example stackoverflow), the cert path always shows like this:
I am not a system admin and not sure how this is done, but anyhow, all I need to do is save the Root CA cert as a *.CER file and add it to the jdk's cacert folder.
After that, the command "mvn clean install" runs to complete with no error

Related

Cannot assign requested address: connect

I'm getting this error when I call any Maven command:
[ERROR] Plugin org.apache.maven.plugins:maven-enforcer-plugin:3.1.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-enforcer-plugin:jar:3.1.0: Could not transfer artifact org.apache.maven.plugins:maven-enforcer-plugin:pom:3.1.0 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/3.1.0/maven-enforcer-plugin-3.1.0.pom: Cannot assign requested address: connect -> [Help 1]
Things that I've already checked:
1. Windows Firewall is not blocking outbound/inbound requests
2. Not behind any proxy
3. Connected to the internet
4. Settings file credentials and repo url OK <settings>
<servers>
<server>
<id>maven-snapshots</id>
<username>dummy-username</username>
<password>dummy-pwd</password>
</server>
<server>
<id>maven-releases</id>
<username>dummy-username</username>
<password>dummy-pwd</password>
</server>
</servers>
<activeProfiles>
<activeProfile>local</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>local</id>
<repositories>
<repository>
<id>maven-releases</id>
<url>https://dev-repo.tech5-sa.com/repository/maven-releases/</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>
5. Can access repo using browser
6. Cleaned caches
This was also happening with Gradle - this: Cannot assign requested address: connect - , before I switch the project to be under Maven control, so I'm guessing, some configuration in the machine (Machine is new).
Java version: 11.0.16
Apache Maven 3.8.7
IntelliJ IDEA 2022.3.1
Build #IC-223.8214.52, built on December 20, 202
Can anyone give me some hints ?
Thank You for your time.
Leo

JAVA deploy first maven project failed

Please tell me what i do wrong.
I download maven project from springboot.io and import to IDE(intelliJ).
Start to deploy I get error
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy
> (default-deploy) on project securing-web-initial: Deployment failed:
> repository element was not specified in the POM inside
> distributionManagement element or in
> -DaltDeploymentRepository=id::layout::url parameter -> [Help 1] [ERROR]
I read like this Problem with deploying spring boot application and add to POM.xml
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Internal repo</name>
<url>E:\!Distrib\repo</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>example-repo</id>
<name>Example Repository</name>
<url>
E:\!Distrib\repo
</url>
</repository>
</repositories>
Nothing changed.
If I use a URL C:\!Users\tgdavies\testrepo I get the error message: Failed to deploy artifacts/metadata: Cannot access C:\!Users\tgdavies\testrepo with type default using the available connector factories: BasicRepositoryConnectorFactory
If I use file:C:\Users\tgdavies\testrepo deploy succeeds.
But your issue is that you do not need to run mvn deploy. Read the tutorial you linked to -- it does not suggest running mvn deploy. To test your code
If you use Maven, you can run the application by using ./mvnw spring-boot:run. Alternatively, you can build the JAR file with ./mvnw clean package and then run the JAR file, as follows:
java -jar target/gs-rest-service-0.1.0.jar
Import I made correctly. It is very easy. I suggested it need a lot of task after import maven project because Run button was not active. As additional automatically was open maven window with deploy and install items)).
intelliJ did not make configuration for run. As a result run button was not active.

How do I stop online searching by maven connectors?

How do I stop the online searching by maven m2e connectors for the dependencies when I have already overridden the functionality for them to have local library instead of central by pom file by giving url like :
<repository>
<id>central</id>
<url>file://${basedir}/library</url>
</repository>
My all other files get downloaded(I mean copied) from the library which exists at local except some which I have not included in the library. Is there any way that connector too only search for the local library. My log is something like below.
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------
[INFO] Total time: 5.413 s
[INFO] Finished at: 2017-09-18T15:22:36-05:00
[INFO] Final Memory: 12M/125M
[INFO] ------------------------------------------------------------------
------
[ERROR] Failed to execute goal on project myproject: Could not resolve
dependencies for project com.company.product:myproject:jar:1.0: Failed to
collect dependencies at org.glassfish.jersey.media:jersey-media-json-
jackson:jar:2.19 -> com.fasterxml.jackson.jaxrs:jackson-jaxrs-
base:jar:2.5.1 -> com.fasterxml.jackson.core:jackson-core:jar:2.5.1:
Failed to read artifact descriptor for
com.fasterxml.jackson.core:jackson-core:jar:2.5.1: Could not transfer
artifact com.fasterxml.jackson.core:jackson-core:pom:2.5.1 from/to
release.maven.java.net (https://maven.java.net/content/groups/public):
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target -> [Help 1]
[ERROR]
Here I am running package as a goal. I can provide more details if you ask.
Quite simple, ask your central repository to get redirected to local repository in your settings.xml file. Example given below. Let me know if further help required.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<mirrors>
<mirror>
<id>central-repo</id>
<name>Local repo</name>
<url>http://<localhost>/central</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
...
</settings>
You can try -o option (offline).
Example command line:
mvn clean package -o

maven settings.xml properties are not seen in pom

i have in settings.xml following config
<profile>
<properties>
<nexus.host>http://localhost:8081/nexus/content/repositories</nexus.host>
</properties>
</profile>
this profile is set as active.
its used in distribution management section of pom
<distributionManagement>
<snapshotRepository>
<id>my-snapshots</id>
<name>my snapshots</name>
<url>${nexus.path}/snapshots</url>
</snapshotRepository>
<repository>
<id>my-releases</id>
<name>my releases</name>
<url>${nexus.path}/releases</url>
</repository>
</distributionManagement>
this works when i run it on local machine, but when the job is executed on jenkins it fails with
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to transfer
com.myapp:sample:pom:1.1.0 from ${nexus.path}/releases was cached in
the local repository, resolution will not be reattempted until the
update interval of my-releases has elapsed or updates are forced.
Original error: Could not transfer artifact com.myapp:sample:pom:1.1.0
from/to my-releases (${nexus.path}/releases): Cannot access
${nexus.path}/releases with type default using the available connector
factories: WagonRepositoryConnectorFactory and 'parent.relativePath'
points at wrong local POM # line 3, column 13
unable to identify the cause of the error
I had the same issue in the past. To resolve this in Jenkins you will need to set the Maven argument so it can find the location of your settings.xml.
You will need to have the settings.xml in the application resources so Jenkins can find it.
To set the argument(In Jenkins, it should be under Goals and options):
-s src/main/resources/settings.xml
However in my instance the Jenkins administrators provided a separate version of maven so the application will have the needed settings.xml and there was no need to provide our own custom settings.xml.
On a side note, you might want to contact the Jenkins Administrators to ensure that they have implemented the proper configurations so Jenkins will be able to deploy the produced artifacts to the repository under the id you have specified.

Accessing maven repo requiring windows creds with a mac

I'm trying to accessing a server with a maven repo. From my windows machine at work I can access it with my company login. With my mac I can access the server if I connect to it and enter in my windows credentials.
Here is the part of my pom with the rep:
<repositories>
<repository>
<id>repo.id</id>
<url>file:////servername/MavenRepo</url>
<!-- use snapshot version -->
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
here is the part of the settings.xml that I'm using to try to set credentials to access that maven repo. What am I doing wrong?
<server>
<id>repo.id</id>
<username>domain\username</username>
<password>password</password>
</server>
The error is:
[ERROR] Failed to execute goal on project Company-Project: Could not resolve dependencies for project Company-Project:Company-Project:jar:DEVELOP-1.0-SNAPSHOT: Failed to collect dependencies at Company-ProjectName:Company-ProjectName:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for Company-ProjectName:Company-ProjectName:jar:1.0-SNAPSHOT: Could not transfer artifact Company-ProjectName:Company-ProjectName:pom:1.0-SNAPSHOT from/to com.Company.maven (file:////Server.Company.corpnet.local/JenkinsMavenRepo): Repository path /Server.Company.corpnet.local/JenkinsMavenRepo does not exist, and cannot be created. -> [Help 1]
It seems that maven could not find the repository on the file system.
file:////Server.Company.corpnet.local/JenkinsMavenRepo): Repository path /Server.Company.corpnet.local/JenkinsMavenRepo does not exist
Have you mounted the repository file system correctly?
Check if you can access the directory /Server.Company.corpnet.local/JenkinsMavenRepo in the Terminal.
PS
I always would prefer a repository server such as nexus. Is that an option?
Turns out using windows as a filestore for a maven repo is proprietary. I setup a IIS server (http) pointing to that directory which resolves the issue.

Categories