Monday, October 10, 2022

[SOLVED] Gradle build fails java.security.NoSuchAlgorithmException: Error constructing implementation on raspberry running Ubuntu 20.04

Issue

I am trying to build an empty gradle application with the following build.gradle file.

plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation group: 'org.json', name: 'json', version: '20220924'
    implementation group: 'uk.co.caprica', name: 'vlcj', version: '4.8.1'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
    useJUnitPlatform()
}

When I try to build I get the following error:

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve org.json:json:20220924.
     Required by:
         project :
      > Could not resolve org.json:json:20220924.
         > Could not get resource 'https://repo.maven.apache.org/maven2/org/json/json/20220924/json-20220924.pom'.
            > java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
   > Could not resolve uk.co.caprica:vlcj:4.8.1.
     Required by:
         project :
      > Could not resolve uk.co.caprica:vlcj:4.8.1.
         > Could not get resource 'https://repo.maven.apache.org/maven2/uk/co/caprica/vlcj/4.8.1/vlcj-4.8.1.pom'.
            > java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 22s
1 actionable task: 1 executed

What I tried so far with no success:

  • add maven certificate to jvm cacerts

What I am using

  • gradle 7.4
  • jdk and jre 11
  • ubuntu 20.04 (raspberry aarch64)

The maven repo exists and I am a bit hopeless what should I do. Any suggestions? Thanks in advance if you can help!

UPDATE: As @dave_thompson_085 recommended, I ran the build with stacktrace and got the following error:

java.security.KeyManagementException: problem accessing trust store

Tried to reinstall java but the same problem exist.


Solution

If anyone runs into the same problem as me just set the variable for

javax.net.ssl.trustStore

to where your cacerts are located. For me it was: /usr/lib/jvm/java-11-openjdk-arm64/lib/security/cacerts

If you don't want to add this parameter every time when you are trying to build here is a solid solution for that.



Answered By - Attila Hulej
Answer Checked By - Pedro (WPSolving Volunteer)