If a stack trace shows:
Caused by: java.io.FileNotFoundException: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts (No such file or directory)
There are webposts which advocate copying cacerts like this: https://discuss.gradle.org/t/failure-initializing-default-system-ssl-context/6568/3
This may not be the correct solution. In my case I had openjdk which was pulled in from an apt install of a package which had the jdk as a dependency even though I have JAVA_HOME declared to be the oracle jdk.
Uninstall openjdk and fix the hard coded /usr/bin/java, /usr/bin/javac, /etc/alternatives links.