TL;DR
How to make Eclipse's built-in Maven connect to an HTTPS repository that uses certificate-based authentication?
It seems that m2e is able to find the keystores, but unable to connect. Command-line Maven works like a charm using exactly the same keystores. Run as -> Maven build works with external Maven and not with the embedded one.
Problem
I have a Maven project with a dependency. That dependency is available in a repository that uses SSL certificate-based authentication in addition to regular username-password combination. I need to make it work in Eclipse Luna, with the built-in Maven. All I am able to get is handshake_failure. Investigation of the logs shows that the built-in Maven is unable to find a matching certificate.
When I use Run as -> Maven build with an external Maven, or command-line Maven, it successfully connects to the repository and fetches the artifact exactly as needed.
The interesting thing is, both external and embedded Mavens have the same version (3.2.3).
Setup
I pass these parameters through eclipse.ini:
-Djavax.net.ssl.trustStore=java.cacerts
-Djavax.net.ssl.trustStorePassword=******
-Djavax.net.ssl.keyStore=private.cacerts
-Djavax.net.ssl.keyStorePassword=******
-Djavax.net.debug=ssl,handshake
The trustStore file contains:
the whole certificate chain for the repository I connect to (the chain ends with a self-signed certificate), one of them being stored under the alias repository.location.url (literal repository location here, e.g. myrepository.com)
certificate for maven central
The keyStore file contains an imported PKCS certificate under an alias of the repository.
There seems to be no problem at all with the setup, as the command-line Maven works. If I use external Maven or command-line one, it works. If I swich to embedded one (which is always used for resolving dependencies), handshake error shows up.
What am I doing wrong? I might be missing something completely obvious. Any help would be appreciated.
Options that didn't work for me
Installing certificate to java > jre > lib > security > cacerts
Providing cacerts in java run configuration vm arguments
Updating eclipse to latest versions like mars or neon
Updating maven plugin for eclipse to 1.7.0
Steps that resolved the issue for me
Download certificate file & add in eclipse at Preferences > Remote Systems > SSL > Add
Clear .m2 > repository folder of all existing files
Open eclipse, right-click on project and Select Maven > Update Project. Choose Force Update of Snapshots/Releases
updated on 9/19/2017
If nothing else works, Installing the certificate to Java on your machine # java > jre > lib > security > cacerts can help
I had exactly the same problem: Eclipse could not connect to external maven repository using embedded maven installation in case the repository requires a client SSL certificate.
The problem was solved by upgrading to latest jvm (in my case - 1.8.0u52) and upgrading Eclipse m2e plugin to version 1.6.1 (with Eclipse version 4.4.0).
In your run configurations select your maven build and then select the JRE tab at the top of the dialog. Put your SSL parameters into the VM arguments text-area.
that's what fixed it for me.
I managed to fix it by setting external maven in eclipse.
Eclipse->Window->Preferences->Maven->Installations->Add
Related
I am setting up a new machine with eclipse Oxygen 4.7. I spent some time getting certificates added to CACERTS so that I could access an external maven repository and access the eclipse marketplace. On Friday afternoon I had everything working. I could reach the eclipse marketplace and maven was able to download my dependencies. Over the weekend I rebooted my machine and my certificates no longer work. I am getting...
Caused by:
sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target.
Am I missing a step or doing something wrong when adding my certs? These are my steps...
Download the cert for the maven repo from the website. I can navigate to the site fine in my browser. I use the certificate export tool. I export the cert as base 64.
I add the cert to CACERTS using keytool.
If I restart eclipse the cert will now get picked up and on the first try I am able to connect to the maven repo. This is true for the marketplace certificate as well. If I restart my machine after this (might also be triggered by just restarting eclipse again, I will test this) the certs no longer works.
I only have one version of java installed, jdk1.8.0_202.
I tried explicitly setting the path to CACERTS in the eclipse.ini file but that did not make a difference. I do have the settings.xml set up for maven. As I have issues connecting to both my maven repo and the eclipse market place I do not think settings.xml is the culprit. Any ideas would be most appreciated. Thanks.
I'm planning to create a java maven web project. I would like to know whether I have to install Maven in windows or install maven in eclipse? I'm using windows 10 and eclipse oxygen. My network has some restrictions so I would be adding a proxy in settings.xml.
I have already tried creating a maven project in eclipse with maven embedded in my eclipse, but it was giving multiple errors during jars download.
Please suggest me on which way I should proceed and which way is better, whether I should use maven in eclipse or install in windows and use?
Usually, you use the embedded Maven in Eclipse, which is part of a standard modern Eclipse installation.
If you get errors with jar downloads, this is probably an issue with your network. Whether putting a proxy in the settings.xml is enough to remedy the problem depends on you actual network.
To find out the exact network restrictions, talk to your admin.
I think you should just try use a different network to create your maven project (for example you can use tethering or ask for permission to get around those network restrictions). After that you should be able to use your maven project even offline.
An alternative would be to just download a maven project and change it to your own.
You can try installing maven:
Go to maven's website to install/configure maven for your os
Set Maven's settings.xml
Configure Maven in your eclipse, choose the installed maven rather than embedded
If your have any errors, please post them here.
I'd like to set the ftp servers for deploying from STS as described here: http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploy-ftp.html
It should be in the settings.xml.
According to documentation settings is in either of 2:
The Maven install: $M2_HOME/conf/settings.xml
A user's install: ${user.home}/.m2/settings.xml
Where is the $M2_HOME. In other terms when working from STS(Eclipse), what is the installation folder for maven in this case. I can't find a settings.xml in ${user.home}/.m2/ .
I worked under Windows 7
Those 2 threads are related but do not provide a clear answer that worked for me at least:
maven doesnt seem to be installing with springsource tool suite
Eclipse (STS) + Maven , I have nothing appearing in the screenshot suggested in this last thread.
Thx in advance
I may be off-mark as I've never used STS myself, but if I understand correctly it is just a pre-packaged Eclipse distribution. If I'm correct your installation only contains an embedded version of Maven, but not a command line accessible one. You need to install one from here.
With the 3.x releases of Eclipse I found that you need to have your installation point to an external Maven installation for Eclipse to make use of the settings.xml files. Once you installed a downloaded version you can choose Window -> Preferences -> Maven -> Installations, press Add... and point to the version you just installed.
In Spring Tools Suite (3.6.1):
Windows - Preferences - Maven - User Settings, you can select which global- and user- version of the settings.xml to use.
Global maven settings.xml exist at apache-maven-3.0.4\conf\settings.xml [inside the maven installation]
and
Local maven settings.xml exist at C\Users\[username]\.m2\settings.xml[window OS install on C drive]
I have an existing project in maven which is working fine in other remote env which i
dont have any access, I dont know what is the issue in my env, the same project is working
in other remote env.
My Env Details are:-
Java1.7
Tomcat7.x
Eclipse Juno,Build id: 20120614-1722
Plugin Details: M2E - Maven Integration for Eclipse
The below error is coming while importing the project and after selecting pom.xml.
No marketplace entries found to handle maven-compiler-plugin:2.0.2:compile in Eclipse
Go to Window > Preferences > Maven Installations and then deactivate the Embedded and add your own installation.
I would check:
That Eclipse Maven build settings are using a JDK and not a JRE
Check the actual compiler settings in the POM. Maybe the source and target should be explicitly set to 1.7.
It's also worth checking if this runs properly with mvn from the command line to rule out whether it is truly a Maven or IDE issue.
I am using NetBeans 7. Tried to create a Maven Java project, failed.
In NetBeans
mvn.bat -DarchetypeVersion=1.1 -Darchetype.interactive=false -DgroupId=com.mycompany -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeRepository=http://repo1.maven.org/maven2/ -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.apache.maven.archetypes -Dbasedir=F:\\NetBeansProjects -Dpackage=com.mycompany.mavenproject1 -DartifactId=mavenproject1 "-Dmaven.repo.local=C:\\Documents and Settings\\xxx\\.m2" --batch-mode archetype:generate
It failed, because
Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out: connect
Then copy that command into DOS, it works.
Looks like NetBeans can't connect to internet. Eclipse on the same machine can connect to remote internet.
The issue is that NetBeans 7 comes bundled with an embedded version of Maven. This means that any proxy settings you may have configured under your downloaded Maven distribution are not used by NetBeans.
You have two options:
Tools > Options > Miscellaneous > Maven > Maven Home -- point NetBeans to your existing Maven download; that is, where you have configrued settings.xml with your proxy settings;
Edit path/to/nb7/java/maven/conf/settings.xml with your proxy settings.
Well it is not necessarily internet issue
If you are behind proxies you need to tell maven in settings.xml about proxy
If that lib ins't available on the maven repos download it from official sitre and install it manually
Either
Disable antivirus firewall protection for a while.
Or
Add netbeans in exception list of the firewall.
In my case Avast firewall had blocked connection and I've disabled it for a while and it worked.
That's it !!!