Build failed when deploying to Talend Cloud on Java 17 - Workaround
When running CI Maven commands for publishing artifacts to Talend Cloud after moving to Java 17, you can get this type of build error:
Unable to make field private static volatile java.net.Authenticator
java.net.Authenticator.theAuthenticator accessible: module java.base
does not "opens java.net" to unnamed module XX
To fix this, you need to add some changes to the Maven startup configuration file.
Workaround for Windows users
Add this line to the file
<Maven_home>/bin/mvn.cmd:
set "MAVEN_OPTS=%MAVEN_OPTS% --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/sun.security.x509=ALL-UNNAMED --add-opens=java.base/sun.security.pkcs=ALL-UNNAMED"
Save your changes and restart the build.
Workaround for Linux users
Add this line to the file
<Maven_home>\bin\mvn:
export MAVEN_OPTS="$MAVEN_OPTS \
--add-opens=java.base/java.net=ALL-UNNAMED \
--add-opens=java.base/sun.security.x509=ALL-UNNAMED \
--add-opens=java.base/sun.security.pkcs=ALL-UNNAMED"
Save your changes and restart the build.
Workaround for Jenkins
If you are using Java 17 with a Jenkins server, edit the TALEND_CI_RUN_CONFIG part of the XML file in jenkins_pipeline_simple.zip to add these parameters.
Save your changes and restart the build.