I'm trying to set up a Maven project with NetBeans on a machine behind a proxy.
When I try to build the dependencies, I get the following error:
Plugin org.apache.maven.plugins:maven-dependency-plugin:2.6 or one of
its dependencies could not be resolved: Failed to read artifact
descriptor for
org.apache.maven.plugins:maven-dependency-plugin:jar:2.6: Could not
transfer artifact
org.apache.maven.plugins:maven-dependency-plugin:pom:2.6 from/to
central (https://repo.maven.apache.org/maven2):
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target -> [Help 1]
As stated here, it's probably because of my proxy configuration.
Netbeans itself has access to the internet. Loading plugins etc. works:
A possible solution would be setting the proxy settings in settings.xml:
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>user</username>
<password>****</password>
<host>proxy</host>
<port>8080</port>
</proxy>
However, as the proxy configuration is set globaly, I don't have access to the parameters (user, password, etc.).
Is there any way, to get Maven to using the global proxy, as NetBeans already does, without asking the admin?
Related
My experience is almost exactly like the one who posted here Certification path error when creating Maven project in Eclipse except I haven't been able to fix my problem
I created a blank maven simple web project (in both eclipse and in vscode) but in my pom.xml at the parent tag, I get the following error.
Project build error: Non-resolvable parent POM for
com.group:demo:0.0.1-SNAPSHOT:
org.springframework.boot:spring-boot-starter-parent:pom:2.6.3 failed
to transfer from
https://nexus.company.com/repository/maven-central-proxy/ during a
previous attempt. This failure was cached in the local repository and
resolution is not reattempted until the update interval of
e-maven-central-mirror has elapsed or updates are forced. Original
error: Could not transfer artifact
org.springframework.boot:spring-boot-starter-parent:pom:2.6.3 from/to
e-maven-central-mirror
(https://nexus.company.com/repository/maven-central-proxy/): PKIX path
building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target and
'parent.relativePath' points at no local POM
In my settings.xml, I have my proxies, servers and mirrors tags set with the necessary information. (By my company's setup guide, this is all I should have but even with the proxy tags added, the non-resolvable parent POM error message stays)
<settings>
<servers>
<server>
<id>e-maven-central-mirror</id>
<username>username</username>
<password>tokenpassword</password>
</server>
</servers>
<mirrors>
<mirror>
<!-- Comments about what are happening here -->
<id>e-maven-central-mirror</id>
<mirrorOf>*</mirrorOf>
<url>https://nexus.company.com/repository/maven-central-proxy/</url>
</mirror>
</mirrors>
</settings>
I'm able to access the url with my id and my token password as normal. I've also gone through the trouble of adding the https://nexus.company.com/repository/maven-central-proxy certificate to both my %JAVA_HOME% (Jdk11) and %JRELOC% (Jre8) cacerts using the keytool. (I added to both as I wasn't sure which Java was the one being used)
I have spent a couple days on this and I'm not sure what it is that I'm doing wrong. Any clarification would be greatly appreciated. Thanks
Edit: I have my env variables HTTP_PROXY and HTTPS_PROXY set. Also saw that my nexus certificates were added to my JDK's keystore but not in the JRE's keystore if that's any useful informtation.
Upon the first attempt to create a maven project using IntelliJ, I'm getting the following error even after importing the .cer file into cacerts.
Could not transfer artifact
org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central
(https://repo.maven.apache.org/maven2): PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
Thanks in advance!!!
You are behind a firewall which wants to inspect what you are doing so they inject themselves in the certification path to be able to do so. This also allows them to rewrite the contents you download on the fly if they want to.
The sole reason to use https instead of http is to detect and avoid this exact scenario.
If you trust the owner of the interfering firewall, add its certificates to the JDK keychain to make programs run with that JDK accept this. Note that the JDK you run Maven with inside IntelliJ may not necessarily be the same as the one used by Maven on the command line.
Why my maven cant download in mvn repo? im having this error.
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]
I also tried to set the proxy
<proxies>
<proxy>
<active>true</active>
<protocol>https</protocol>
<host>host</host>
<port>port</port>
</proxy>
but i can also access https://repo.maven.apache.org/maven2 on my chrome.
Looks like your network firewall is blocking and you need to talk to your network admin. You are able to access this from chrome as it is not in blocked list but running maven command executes in different manner.
Also you can make sure this running same application on different system which is not under firewall(maybe on your own laptop)
Im am trying to Maven install and create the jar for my project . but i am getting the following error:
Plugin org.apache.maven.plugins:maven-surefire-plugin:2.19.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.19.1: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.19.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: unknown error: Unknown host repo.maven.apache.org: unknown error -> [Help 1]
Any help appreciated. I have found similar threads but none of them worked. Added the missing plugin like below but still the same issue. Any help is appreciated.
Plug in added:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
Thanks in Advance.
As khmarbaise and lexicore have already mentioned you need to configure your proxy for maven. Please confirm that you are on your company's network. If so:
Find out your proxy
If your using your company's laptop your browser is probably already configured to use the company proxy. This is a good wikihow article for looking up your proxy settings in different browsers. You want to take not of:
Proxy Server Host Name
Proxy Server Port
Proxy Server Username (if there is one)
Proxy Server Password (if there is one)
If the proxy hasn't been configured in your browser by normal methods, you should get in touch with your IT department and ask them for the proxy server details.
Configuring your proxy for maven
Once you have your proxy server settings. Open your ~/.m2/settings.xml file. If it doesn't exist create it. Now fill in the details of your proxy server with the following format:
<settings>
<proxies>
<proxy>
<id>work-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>my.proxy.host.name</host>
<port>proxyport</port>
<username>proxyuser</username> <!-- Remove this option if there is no user name -->
<password>somepassword</password> <!-- Remove this option if there is no password -->
</proxy>
</proxies>
</settings>
The official maven docs for this are here.
Note: If you take your work laptop home and you don't VPN into the company network, you will have to disable this proxy in order for maven to work at home.
I have a Maven project and added db4o as a dependency using this answer from a previous question. When I compile the project it gives me the following error:
Could not resolve dependencies for
project
org.uca.dss:trenes:jar:1.0-SNAPSHOT:
[...] Failed to read artifact
descriptor for
com.db4o:db4o-full-java5:jar:7.13-SNAPSHOT:
Could not transfer artifact
com.db4o:db4o-full-java5:pom:7.13-SNAPSHOT
from/to source.db4o
(https://source.db4o.com/maven/):
Error transferring file:
sun.security.validator.ValidatorException:
PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification
path to requested target -> [Help 1]
Curiously enough, it only happens in Ubuntu GNU/Linux (tested in two PC's), but not in Windows (using NetBeans 7.0).
I can post the full error (from maven -X output), but I think it does not add much information
Edit 1:
This is what I have in my pom.xml file regarding db4o:
<repository>
<id>source.db4o</id>
<url>https://source.db4o.com/maven/</url>
</repository>
...
<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-full-java5</artifactId>
<version>7.13-SNAPSHOT</version>
</dependency>
This looks like a security certificate issue for a secured request which is generally looked up from %JAVA_HOME%\jre\lib\security\cacerts . I am guessing your windows JRE has the entries whereas the ubuntu JRE is lacking them.
By the way this link is a good read on installing certs. You probably want to use the option 1 mentioned there.