Not sure if this is the right place to report this but since the Oracle driver is not Open Source hard to know where to report these kinds of things.
It surprised me that the Oracle JDBC driver version com.oracle.ojdbc:ojdbc8:19.3.0.0 does not support GraalVM substrate native images given that it is from Oracle 馃檪
Currently it fails with:
Caused by: java.lang.NullPointerException: null
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562)
Would be nice if the GraalVM team could work with the Oracle JDBC team to make this work out the box without pushing the problem onto users.
Separate to that it seems the MySQL JDBC driver also does not support GraalVM native out of the box. See https://github.com/micronaut-projects/micronaut-data/issues/123 and https://bugs.mysql.com/bug.php?id=91968
Again MySQL being part of Oracle it would make sense for you folks to collaborate to get those things working without pushing the work on to third parties.
I got Oracle JDBC driver working with:
{
"name":"oracle.jdbc.OracleDriver",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"oracle.jdbc.driver.T4CDriverExtension",
"methods":[{"name":"<init>","parameterTypes":[] }]
}
It would still be nice if the Oracle driver shipped with the above config.
I have written up snapshot documentation for going native with different drivers with Micronaut:
https://micronaut-projects.github.io/micronaut-data/snapshot/guide/#graal
Currently omitted MySQL due to https://bugs.mysql.com/bug.php?id=91968
@graemerocher I have a working ojdbc8 example with the latest GraalVM-19.3.0-dev. The needed config is:
reflect-config.json:[
{
"name":"oracle.jdbc.driver.T4CDriverExtension",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name" : "oracle.jdbc.driver.T2CDriverExtension",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"oracle.net.ano.Ano",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"oracle.net.ano.AuthenticationService",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"oracle.net.ano.DataIntegrityService",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"oracle.net.ano.EncryptionService",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"oracle.net.ano.SupervisorService",
"methods":[{"name":"<init>","parameterTypes":[] }]
}
]
resource-config.json:{
"resources":[
{"pattern":"META-INF/services/java.sql.Driver"},
{"pattern":"oracle/sql/converter_xcharset/lx20002.glb"},
{"pattern":"oracle/sql/converter_xcharset/lx2001f.glb"},
{"pattern":"oracle/sql/converter_xcharset/lx200b2.glb"}
]
}
native-image.properties:Args = --enable-all-security-services \
-H:IncludeResourceBundles=oracle.net.jdbc.nl.mesg.NLSR,oracle.net.mesg.Message \
--allow-incomplete-classpath \
--initialize-at-build-time=oracle.net.jdbc.nl.mesg.NLSR_en \
--initialize-at-build-time=oracle.jdbc.driver.DynamicByteArray,oracle.sql.ConverterArchive,oracle.sql.converter.CharacterConverterJDBC,oracle.sql.converter.CharacterConverter1Byte \
--initialize-at-run-time=java.sql.DriverManager
We are working on shipping the required config by default in the future.
Thanks 馃憤
@cstancu what about postgres and mysql, do you have working configs as well?
No, I've only looked at OJDBC so far.
@s1monw1 for Micronaut at least there are instructions for Postgres here https://micronaut-projects.github.io/micronaut-data/latest/guide/#graalJDBC
@cstancu Is there support for Informix? If not, is there methodology to add it?
@cstancu I am tring to build native-image (quarkus-1.2.0.Final & GraalVM-java11-19.3.1) with ojdbc8-19.3.0.0 using config from comment . But it is not working and build failed with error:
com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
java.sql.DriverManager the class was requested to be initialized at build time (from the command line). java.sql.DriverManager has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked. Try avoiding to initialize the class that caused initialization of java.sql.DriverManager
at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:510)
at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:187)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:710)
at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:710)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Error: Image build request failed with exit status 1
I solved my problem by using config from this comment
@iustinov Hi, did you just copy the config of the 3 files?
Because I'm trying to make things work but with that config I get a lot of errors in the compilation stage about the runtime loading classes. Am I forgetting something?
@cstancu Hello! Any updates on the MySQL side? Do you have any configuration information for it?
@shahmirn the MySQL driver works fine in native-image if you use Quarkus to build. Feel free to look at the quarkus extension sources to learn how to apply the same on another application, in case you don't want to use Quarkus:
@Sanne Works fine in Micronaut as well. Point of this issue is these drivers should work in native image without the need for framework specific integration
Good point - and I certainly look forward for OOB support for the Oracle JDBC driver too :)
I can try sending some patches to the MySQL team (like I did with PostgreSQL in the past for my first POC) - but I expect an uphill discussion as I won't be able to make time to add all infrastructure for GraalVM integration tests, maybe you could help?
Let me find out who can help us. Currently away this week and next. Will get back to you
Most helpful comment
Let me find out who can help us. Currently away this week and next. Will get back to you