After upgrading to Java
JDK 11 jobs executing
Groovy code which were reliying on installed extensions (
JAR files in the
lib/ext directory of the Java Runtime Environment) are failing with
import groovy.sql.Sql def driver = "com.mysql.cj.jdbc.Driver" def user = "sample_user" def password = "sample_password" def url = "jdbc:mysql://sample-host.com" def db = Sql.newInstance(url, user, password, driver)
It throws a
java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver exeception.
lib/ext directory was removed starting in
JDK 9, and the presence of this directory will force
javac executables to exit. Check Java Platform, Standard Edition Oracle JDK 9 Migration Guide: Removed Extension Mechanism for more details about it.
|This process is unsupported, and if any issues are caused by doing this we will ask you to revert this change before we can escalate the issue to engineering. The correct solution to solve this problem is to integrate this into a Jenkins plugin.|
You now need to add any third-party
JAR files to the application’s classpath:
The build classpath if there are compile time dependencies
The runtime classpath if there are runtime dependencies