A bug block the Mongo refactoring for cluster #4529.
Mongo Operations. Java in panache Mongo module try to load config quarkus.mongodb.database.
But it fail on native. Whereas it is in application.properties and work well in regular mode.
If I add application.properties to NativeImageResourceBuildItem it work but it is not an expected behavior.
BTW, it is odd to use database property because, it can be inside connection string too.
Best is too defined and use it only on Mongodb module and only select database if specified on panash entity.
Ps you can see full stack on azure last build of #3343
ON mongodb panache integration test:
Stack trace:
ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-worker-thread-0) HTTP Request to /persons/repository failed, error id: b503008a-2200-4948-8808-80ba7af55379-1: org.jboss.resteasy.spi.UnhandledException: java.util.NoSuchElementException: Property quarkus.mongodb.database not found
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:209)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:108)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatchRequestContext(VertxRequestHandler.java:83)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.lambda$handle$0(VertxRequestHandler.java:70)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
Caused by: java.util.NoSuchElementException: Property quarkus.mongodb.database not found
at io.smallrye.config.SmallRyeConfig.propertyNotFound(SmallRyeConfig.java:221)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:112)
at io.quarkus.mongodb.panache.runtime.MongoOperations.mongoDatabase(MongoOperations.java:273)
at io.quarkus.mongodb.panache.runtime.MongoOperations.mongoCollection(MongoOperations.java:177)
at io.quarkus.mongodb.panache.runtime.MongoOperations.findAll(MongoOperations.java:445)
at io.quarkus.mongodb.panache.runtime.MongoOperations.listAll(MongoOperations.java:469)
at io.quarkus.it.mongodb.panache.person.PersonRepository.listAll(PersonRepository.java)
at io.quarkus.it.mongodb.panache.person.PersonRepository_ClientProxy.listAll(PersonRepository_ClientProxy.zig:1599)
at io.quarkus.it.mongodb.panache.person.PersonRepositoryResource.getPersons(PersonRepositoryResource.java:26)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:151)
at org.jboss.resteasy.core.MethodInjectorImpl.lambda$invoke$3(MethodInjectorImpl.java:122)
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616)
at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:628)
at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:1996)
at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:110)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:122)
at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:594)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:468)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:421)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:423)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:391)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invoke$1(ResourceMethodInvoker.java:365)
at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:995)
at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2137)
at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:110)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:365)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)`
Can you give a stack trace?
Don't forget that we don't support SRV in native.
I have update jira.
What do you mean by SRV ?
@cescoffier this has nothing to do with SRV mongodb URI.
The issue can be express more simply like this:
I have the following in application.properties
quarkus.mongodb.database=toto
The following code works in JVM but not in native:
String dbName = ConfigProvider.getConfig("quarkus.mongodb.database");
In native the config property is not found:
Caused by: java.util.NoSuchElementException: Property quarkus.mongodb.database not found
As an help to find the issue, adding application.properties as a NativeResourceBuildItem workaround the issue but we're against it as it should not be needed.
cc @dmlloyd
@dufoli @loicmathieu can you please try ConfigProviderResolver.instance().getConfig().getConfig("quarkus.mongodb.database")?
/cc @dmlloyd
@loicmathieu thanks to make the explanation clearer.
I just add that definition of config is done inside MongoDb module and use of config is done inside panache mongodb module.
Either way this is likely fixed by #5387.
@geoand sadly still failing with the change.
@dufoli @geoand I was afraid that it changes nothing as I'm pretty sure that I tested it (but we tested so much things that I was not 100% sure anymore ...)
If @dmlloyd thinks that #5387 will fix this, does we wait for it to be merged, I don't know if it will be sooner or later.
@dufoli what you can do to be 100% sure is to try to rebase locally on https://github.com/dmlloyd/quarkus/tree/config-updates-final and test locally the native integration test
The problem was that the original config properties weren't replicated into the target artifact if they didn't have a run time visible scope. That was changed in #5387; now all configuration properties that were set at build are copied into the native image.
@dmlloyd quarkus.mongodb.database is a runtime property.
And it works before the changes dones by @dufoli for mutiple mongo connection support.
@loicmathieu @geoand @dmlloyd great news, with 5387, I have succeed to build the module and run integration test.
command run
./mvnw clean install -Pnative
@loicmathieu I have change config from runtime to BUILD_AND_RUN_TIME_FIXED. Maybe it come from that...
@dufoli maybe close this issue and add a note on #4529 that it is waiting for #5387 ?
I don't know if there is a plan to merge #5387 soon ...
Most helpful comment
@loicmathieu @geoand @dmlloyd great news, with 5387, I have succeed to build the module and run integration test.
command run
./mvnw clean install -Pnative