Native build failed with h2 as test DB

672 views
Skip to first unread message

Anthony Viard

unread,
Mar 15, 2021, 1:29:52 PM3/15/21
to Quarkus Development mailing list
Hi there,
I'm a JHipster core contributor and I'm working on the Quarkus implementation (https://github.com/jhipster/generator-jhipster-quarkus).

I'm trying to add a GitHub actions workflow to ensure the native builds work as expected (I'm using a matrix GH workflow to test different configurations). With some configurations, the native build is always failing with an error related to h2.

"Unable to find a JDBC driver corresponding to the database kind 'h2' for the default datasource. Either provide a suitable JDBC driver extension, define the driver manually, or disable the JDBC datasource by adding 'quarkus.datasource.jdbc=false' to your configuration if you don't need it."

The reproducer is available here: https://github.com/avdev4j/sample-h2-failing-native

I'm using GraalVM CE 21.0.0.2 and I launch the native build like this: ./mvnw clean verify -Pnative

The failing test class is always this one MailServiceIT.

I'm struggling on finding a way to make it works. Of course, skipping the tests is a solution but I can't figure out how to build it without errors. 

I'm glad if you can help me to understand what happened here, and If we did something wrong with our configuration.

Thanks for the help.

Regards,

Anthony

FYI the full log is :

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running io.github.jhipster.sample.service.MailServiceIT
Mar 15, 2021 4:32:26 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.2.0.Final
[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 2, Time elapsed: 1.347 s <<< FAILURE! - in io.github.jhipster.sample.service.MailServiceIT
[ERROR] io.github.jhipster.sample.service.MailServiceIT.should_containsActivationInfosWhenCallSendCreationEmail  Time elapsed: 0.003 s  <<< ERROR!
java.lang.RuntimeException:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.agroal.deployment.AgroalProcessor#build threw an exception: io.quarkus.runtime.configuration.ConfigurationException: Unable to find a JDBC driver corresponding to the database kind 'h2' for the default datasource. Either provide a suitable JDBC driver extension, define the driver manually, or disable the JDBC datasource by adding 'quarkus.datasource.jdbc=false' to your configuration if you don't need it.
at io.quarkus.agroal.deployment.AgroalProcessor.resolveDriver(AgroalProcessor.java:320)
at io.quarkus.agroal.deployment.AgroalProcessor.getAggregatedConfigBuildItems(AgroalProcessor.java:274)
at io.quarkus.agroal.deployment.AgroalProcessor.build(AgroalProcessor.java:83)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:920)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)

Caused by: java.lang.RuntimeException:
io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.agroal.deployment.AgroalProcessor#build threw an exception: io.quarkus.runtime.configuration.ConfigurationException: Unable to find a JDBC driver corresponding to the database kind 'h2' for the default datasource. Either provide a suitable JDBC driver extension, define the driver manually, or disable the JDBC datasource by adding 'quarkus.datasource.jdbc=false' to your configuration if you don't need it.
at io.quarkus.agroal.deployment.AgroalProcessor.resolveDriver(AgroalProcessor.java:320)
at io.quarkus.agroal.deployment.AgroalProcessor.getAggregatedConfigBuildItems(AgroalProcessor.java:274)
at io.quarkus.agroal.deployment.AgroalProcessor.build(AgroalProcessor.java:83)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:920)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)

Caused by: io.quarkus.builder.BuildException:
Build failure: Build failed due to errors
[error]: Build step io.quarkus.agroal.deployment.AgroalProcessor#build threw an exception: io.quarkus.runtime.configuration.ConfigurationException: Unable to find a JDBC driver corresponding to the database kind 'h2' for the default datasource. Either provide a suitable JDBC driver extension, define the driver manually, or disable the JDBC datasource by adding 'quarkus.datasource.jdbc=false' to your configuration if you don't need it.
at io.quarkus.agroal.deployment.AgroalProcessor.resolveDriver(AgroalProcessor.java:320)
at io.quarkus.agroal.deployment.AgroalProcessor.getAggregatedConfigBuildItems(AgroalProcessor.java:274)
at io.quarkus.agroal.deployment.AgroalProcessor.build(AgroalProcessor.java:83)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:920)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)

Caused by: io.quarkus.runtime.configuration.ConfigurationException: Unable to find a JDBC driver corresponding to the database kind 'h2' for the default datasource. Either provide a suitable JDBC driver extension, define the driver manually, or disable the JDBC datasource by adding 'quarkus.datasource.jdbc=false' to your configuration if you don't need it.

Stuart Douglas

unread,
Mar 15, 2021, 6:43:06 PM3/15/21
to anth....@gmail.com, Quarkus Development mailing list
So I thought you needed to do something like:

quarkus.test.native-image-profile=prod

(or some other profile that has a MySQL database URL).

Native images are compiled in prod mode (as they are production images), so you can't test them against H2 if you are compiling against mysql.

However it turns out that MailServiceIT is not even a native test, it is a JVM test, so the issue is that test scoped deps don't seem to be added to integration tests, the fix is to just rename it so it runs in the test phase instead of the integration test phase with the rest of the tests.

Stuart

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/fea1bf33-f59b-44d7-805f-ae673720357fn%40googlegroups.com.

Anthony Viard

unread,
Mar 18, 2021, 12:27:18 PM3/18/21
to Quarkus Development mailing list
Hi Stuart,
thanks for the help! Indeed the way we are testing the app is not ideal (especially in native mode). 
Rename the test fixed the issue but I think we should reconsider how the tests are made.

Btw we have an opened issue on this specific subject with a 200$ bug bounty on it. If anybody wants to make a bit of money by contributing to the project, we will glad to help him. https://github.com/jhipster/generator-jhipster-quarkus/issues/49

Anthony
Reply all
Reply to author
Forward
0 new messages