Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use MongoDB with Panache with multiple clients on the same instance #10812

Closed
ekans opened this issue Jul 17, 2020 · 5 comments · Fixed by #11058
Closed

Can't use MongoDB with Panache with multiple clients on the same instance #10812

ekans opened this issue Jul 17, 2020 · 5 comments · Fixed by #11058
Assignees
Labels
Milestone

Comments

@ekans
Copy link

ekans commented Jul 17, 2020

Describe the bug
I have a MongoDB instance and several databases.
I don't manage to use MongoDB with Panache for several entities on different databases.

Here a simplified version of my Kotlin code :

@MongoEntity(clientName = "db1", collection = "c1")
data class C1 @BsonCreator constructor(
  @BsonId var id: ObjectId = ObjectId()
) : PanacheMongoEntityBase()

My application.properties:

quarkus.mongodb.db1.connection-string=mongodb://127.0.0.1:27017
quarkus.mongodb.db1.database=db1-name

I have the following error:

org.jboss.resteasy.spi.UnhandledException: java.util.NoSuchElementException: Property quarkus.mongodb.database not found

I was expected that the database name was retrieved from quarkus.mongodb.db1.database.
Am I missing something?

To Reproduce
Here is a reproducer

Environment (please complete the following information):

  • Output of uname -a or ver:
Linux Envy 5.4.0-40-generic #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version:
openjdk version "1.8.0_252"
OpenJDK Runtime Environment Corretto-8.252.09.1 (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM Corretto-8.252.09.1 (build 25.252-b09, mixed mode)
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.6.0.Final
  • Build tool (ie. output of mvnw --version or gradlew --version):
Maven home: .../.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 1.8.0_252, vendor: Amazon.com Inc., runtime: .../java/corretto-8.252.09.1/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-40-generic", arch: "amd64", family: "unix"
@ekans ekans added the kind/bug Something isn't working label Jul 17, 2020
@quarkusbot
Copy link

/cc @FroMage, @loicmathieu
/cc @loicmathieu

@FroMage
Copy link
Member

FroMage commented Jul 20, 2020

Can you give us a full stack trace please?

@ekans
Copy link
Author

ekans commented Jul 20, 2020

I discussed on zulip with @loicmathieu about this issue.
I proposed my help to fix this issue but I'm currently stuck on running tests.
Btw is it better to discuss here or on zulip?

To get back to your request here is the full stack trace:

java.util.NoSuchElementException: SRCFG00014: Property quarkus.mongodb.database not found

	at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:161)
	at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:145)
	at io.quarkus.mongodb.panache.runtime.MongoOperations.getDefaultDatabaseName(MongoOperations.java:291)
	at io.quarkus.mongodb.panache.runtime.MongoOperations.mongoDatabase(MongoOperations.java:282)
	at io.quarkus.mongodb.panache.runtime.MongoOperations.mongoCollection(MongoOperations.java:187)
	at io.quarkus.mongodb.panache.runtime.MongoOperations.deleteAll(MongoOperations.java:585)
	at org.acme.mongodb.panache.PersonDB1Repository.deleteAll(PersonDB1Repository.java)
	at org.acme.mongodb.panache.PersonDB1Repository_ClientProxy.deleteAll(PersonDB1Repository_ClientProxy.zig:931)
	at org.acme.mongodb.panache.PersonRepositoryTest.test(PersonRepositoryTest.java:19)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:618)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestMethod(QuarkusTestExtension.java:526)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

@geoand
Copy link
Contributor

geoand commented Jul 29, 2020

I'm gonna take this one as I think it has a tad more complexity than appears initially and it would be good to have a fix for 1.7.0.CR1

@geoand
Copy link
Contributor

geoand commented Jul 29, 2020

I'm facing a weird Arc issue which is why I haven't opened a PR yet - I'll ping you when I do

geoand added a commit to geoand/quarkus that referenced this issue Jul 29, 2020
geoand pushed a commit to geoand/quarkus that referenced this issue Jul 29, 2020
geoand added a commit to geoand/quarkus that referenced this issue Jul 29, 2020
geoand pushed a commit to geoand/quarkus that referenced this issue Jul 29, 2020
geoand added a commit to geoand/quarkus that referenced this issue Jul 29, 2020
geoand pushed a commit to geoand/quarkus that referenced this issue Jul 29, 2020
geoand added a commit to geoand/quarkus that referenced this issue Jul 29, 2020
geoand pushed a commit to geoand/quarkus that referenced this issue Jul 29, 2020
gsmet added a commit that referenced this issue Jul 29, 2020
Fix MongoClient handling in Mongo Panache
@gsmet gsmet added this to the 1.7.0 - master milestone Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants