Recently I tried to deploy my Java project as a single fat jar. To my bad awekening, Maven did not feel like creating jars anymore and complained with errors like :
You might encounter an error like this, if you recently reinstalled your java and want to build Jar with maven
1 |
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty |
Or
1 |
java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty |
Or
1 |
java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty |
Or
1 |
Could not resolve dependencies for project com.gt-arc.coda:repo:jar:0.0.3-SNAPSHOT: Failed to collect dependencies at com.sun.jersey:jersey-core:jar:1.9.1: Failed to read artifact descriptor for com.sun.jersey:jersey-core:jar:1.9.1: Could not transfer artifact com.sun.jersey:jersey-core:pom:1.9.1 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [Help 1] |
Or
1 |
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project repo: Could not resolve dependencies for project com.gt-arc.coda:repo:jar:0.0.3-SNAPSHOT: Failed to collect dependencies at com.sun.jersey:jersey-core:jar:1.9.1 |
Or
1 |
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at com.sun.jersey:jersey-core:jar:1.9.1 |
Or
1 |
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for com.sun.jersey:jersey-core:jar:1.9.1 |
Or
1 |
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact com.sun.jersey:jersey-core:pom:1.9.1 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty |
The console with spit something like this out :
How to fix the error
To fix the error, we will download the java JDK and extract the certificates into our local java installation.
Get java
1 |
wget http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.rpm |
Extract the jdk
1 |
tar -xzf jdk-8u171-linux-x64.tar.gz |
Copy the Certificate into your java directory
1 |
sudo cp -i /path/to/java/jdk/jdk1.8.0_171/jre/lib/security/cacerts /etc/ssl/certs/java |
And now you can finally build your jar with
1 |
mvn clean compile assembly:single |