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

Two MyBatis SQL session factories created with XML config #199

Open
franck102 opened this issue Jun 9, 2022 · 1 comment
Open

Two MyBatis SQL session factories created with XML config #199

franck102 opened this issue Jun 9, 2022 · 1 comment

Comments

@franck102
Copy link

When I enable XML config with those properties:

quarkus.mybatis.xmlconfig.enable=true
quarkus.mybatis.xmlconfig.path=mybatis/config.xml
quarkus.mybatis.environment=dev
quarkus.mybatis.auto-mapping-unknown-column-behavior=warning
quarkus.mybatis.map-underscore-to-camel-case=true
quarkus.mybatis.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl

those two build steps are executed:
io.quarkiverse.mybatis.deployment.MyBatisProcessor#generateSqlSessionFactoryFromXmlConfig
io.quarkiverse.mybatis.deployment.MyBatisProcessor#generateSqlSessionFactory

and the application ends with two instances of org.apache.ibatis.session.Configuration and two instances of SQLSessionFactory; only the XML one is correctly configured, the other one has no mapped statements. It happens to be the one picked up by injection so I get "statement not bound" errors for all mapper methods.

io.quarkiverse.mybatis.runtime.MyBatisRecorder#createSqlSessionFactory called from generateSqlSessionFactory get a MyBatisruntimeConfig with xmlconfig.enabled = true, but it ignores that and doesn't load the XML.

Here are the stack traces for the two build steps:

Stack trace #1:


<init>:42, DefaultSqlSessionFactory (org.apache.ibatis.session.defaults)
build:92, SqlSessionFactoryBuilder (org.apache.ibatis.session)
createSqlSessionFactory:65, MyBatisRecorder (io.quarkiverse.mybatis.runtime)
deploy_0:-1, MyBatisProcessor$generateSqlSessionFactoryFromXmlConfig283316845 (io.quarkus.deployment.steps)
deploy:-1, MyBatisProcessor$generateSqlSessionFactoryFromXmlConfig283316845 (io.quarkus.deployment.steps)
<clinit>:-1, ApplicationImpl (io.quarkus.runner)
forName0:-1, Class (java.lang)
forName:488, Class (java.lang)
forName:467, Class (java.lang)
run:221, StartupActionImpl (io.quarkus.runner.bootstrap)
doJavaStart:250, QuarkusTestExtension (io.quarkus.test.junit)
ensureStarted:609, QuarkusTestExtension (io.quarkus.test.junit)
beforeAll:647, QuarkusTestExtension (io.quarkus.test.junit)
lambda$invokeBeforeAllCallbacks$10:381, ClassBasedTestDescriptor (org.junit.jupiter.engine.descriptor)
execute:-1, ClassBasedTestDescriptor$$Lambda$339/0x0000000800cb7010 (org.junit.jupiter.engine.descriptor)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
invokeBeforeAllCallbacks:381, ClassBasedTestDescriptor (org.junit.jupiter.engine.descriptor)
before:205, ClassBasedTestDescriptor (org.junit.jupiter.engine.descriptor)
before:80, ClassBasedTestDescriptor (org.junit.jupiter.engine.descriptor)
lambda$executeRecursively$6:148, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, NodeTestTask$$Lambda$288/0x0000000800ca7ad8 (org.junit.platform.engine.support.hierarchical)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$8:141, NodeTestTask (org.junit.platform.engine.support.hierarchical)
invoke:-1, NodeTestTask$$Lambda$287/0x0000000800ca7630 (org.junit.platform.engine.support.hierarchical)
around:137, Node (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$9:139, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, NodeTestTask$$Lambda$286/0x0000000800ca7238 (org.junit.platform.engine.support.hierarchical)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
executeRecursively:138, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:95, NodeTestTask (org.junit.platform.engine.support.hierarchical)
accept:-1, SameThreadHierarchicalTestExecutorService$$Lambda$292/0x0000000800ca5b90 (org.junit.platform.engine.support.hierarchical)
forEach:1511, ArrayList (java.util)
invokeAll:41, SameThreadHierarchicalTestExecutorService (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$6:155, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, NodeTestTask$$Lambda$288/0x0000000800ca7ad8 (org.junit.platform.engine.support.hierarchical)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$8:141, NodeTestTask (org.junit.platform.engine.support.hierarchical)
invoke:-1, NodeTestTask$$Lambda$287/0x0000000800ca7630 (org.junit.platform.engine.support.hierarchical)
around:137, Node (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$9:139, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, NodeTestTask$$Lambda$286/0x0000000800ca7238 (org.junit.platform.engine.support.hierarchical)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
executeRecursively:138, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:95, NodeTestTask (org.junit.platform.engine.support.hierarchical)
submit:35, SameThreadHierarchicalTestExecutorService (org.junit.platform.engine.support.hierarchical)
execute:57, HierarchicalTestExecutor (org.junit.platform.engine.support.hierarchical)
execute:54, HierarchicalTestEngine (org.junit.platform.engine.support.hierarchical)
execute:107, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
execute:88, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
lambda$execute$0:54, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
accept:-1, EngineExecutionOrchestrator$$Lambda$236/0x0000000800c91740 (org.junit.platform.launcher.core)
withInterceptedStreams:67, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
execute:52, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
execute:114, DefaultLauncher (org.junit.platform.launcher.core)
execute:86, DefaultLauncher (org.junit.platform.launcher.core)
execute:86, DefaultLauncherSession$DelegatingLauncher (org.junit.platform.launcher.core)
execute:53, SessionPerRequestLauncher (org.junit.platform.launcher.core)
startRunnerWithArgs:71, JUnit5IdeaTestRunner (com.intellij.junit5)
execute:38, IdeaTestRunner$Repeater$1 (com.intellij.rt.junit)
repeat:11, TestsRepeater (com.intellij.rt.execution.junit)
startRunnerWithArgs:35, IdeaTestRunner$Repeater (com.intellij.rt.junit)
prepareStreamsAndStart:235, JUnitStarter (com.intellij.rt.junit)
main:54, JUnitStarter (com.intellij.rt.junit)

Stack trace #2


<init>:42, DefaultSqlSessionFactory (org.apache.ibatis.session.defaults)
build:92, SqlSessionFactoryBuilder (org.apache.ibatis.session)
createSqlSessionFactory:85, MyBatisRecorder (io.quarkiverse.mybatis.runtime)
deploy_0:-1, MyBatisProcessor$generateSqlSessionFactory1685105135 (io.quarkus.deployment.steps)
deploy:-1, MyBatisProcessor$generateSqlSessionFactory1685105135 (io.quarkus.deployment.steps)
<clinit>:-1, ApplicationImpl (io.quarkus.runner)
forName0:-1, Class (java.lang)
forName:488, Class (java.lang)
forName:467, Class (java.lang)
run:221, StartupActionImpl (io.quarkus.runner.bootstrap)
doJavaStart:250, QuarkusTestExtension (io.quarkus.test.junit)
ensureStarted:609, QuarkusTestExtension (io.quarkus.test.junit)
beforeAll:647, QuarkusTestExtension (io.quarkus.test.junit)
lambda$invokeBeforeAllCallbacks$10:381, ClassBasedTestDescriptor (org.junit.jupiter.engine.descriptor)
execute:-1, ClassBasedTestDescriptor$$Lambda$339/0x0000000800cb7010 (org.junit.jupiter.engine.descriptor)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
invokeBeforeAllCallbacks:381, ClassBasedTestDescriptor (org.junit.jupiter.engine.descriptor)
before:205, ClassBasedTestDescriptor (org.junit.jupiter.engine.descriptor)
before:80, ClassBasedTestDescriptor (org.junit.jupiter.engine.descriptor)
lambda$executeRecursively$6:148, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, NodeTestTask$$Lambda$288/0x0000000800ca7ad8 (org.junit.platform.engine.support.hierarchical)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$8:141, NodeTestTask (org.junit.platform.engine.support.hierarchical)
invoke:-1, NodeTestTask$$Lambda$287/0x0000000800ca7630 (org.junit.platform.engine.support.hierarchical)
around:137, Node (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$9:139, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, NodeTestTask$$Lambda$286/0x0000000800ca7238 (org.junit.platform.engine.support.hierarchical)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
executeRecursively:138, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:95, NodeTestTask (org.junit.platform.engine.support.hierarchical)
accept:-1, SameThreadHierarchicalTestExecutorService$$Lambda$292/0x0000000800ca5b90 (org.junit.platform.engine.support.hierarchical)
forEach:1511, ArrayList (java.util)
invokeAll:41, SameThreadHierarchicalTestExecutorService (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$6:155, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, NodeTestTask$$Lambda$288/0x0000000800ca7ad8 (org.junit.platform.engine.support.hierarchical)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$8:141, NodeTestTask (org.junit.platform.engine.support.hierarchical)
invoke:-1, NodeTestTask$$Lambda$287/0x0000000800ca7630 (org.junit.platform.engine.support.hierarchical)
around:137, Node (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$9:139, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, NodeTestTask$$Lambda$286/0x0000000800ca7238 (org.junit.platform.engine.support.hierarchical)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
executeRecursively:138, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:95, NodeTestTask (org.junit.platform.engine.support.hierarchical)
submit:35, SameThreadHierarchicalTestExecutorService (org.junit.platform.engine.support.hierarchical)
execute:57, HierarchicalTestExecutor (org.junit.platform.engine.support.hierarchical)
execute:54, HierarchicalTestEngine (org.junit.platform.engine.support.hierarchical)
execute:107, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
execute:88, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
lambda$execute$0:54, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
accept:-1, EngineExecutionOrchestrator$$Lambda$236/0x0000000800c91740 (org.junit.platform.launcher.core)
withInterceptedStreams:67, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
execute:52, EngineExecutionOrchestrator (org.junit.platform.launcher.core)
execute:114, DefaultLauncher (org.junit.platform.launcher.core)
execute:86, DefaultLauncher (org.junit.platform.launcher.core)
execute:86, DefaultLauncherSession$DelegatingLauncher (org.junit.platform.launcher.core)
execute:53, SessionPerRequestLauncher (org.junit.platform.launcher.core)
startRunnerWithArgs:71, JUnit5IdeaTestRunner (com.intellij.junit5)
execute:38, IdeaTestRunner$Repeater$1 (com.intellij.rt.junit)
repeat:11, TestsRepeater (com.intellij.rt.execution.junit)
startRunnerWithArgs:35, IdeaTestRunner$Repeater (com.intellij.rt.junit)
prepareStreamsAndStart:235, JUnitStarter (com.intellij.rt.junit)
main:54, JUnitStarter (com.intellij.rt.junit)
@zhfeng
Copy link
Collaborator

zhfeng commented Jun 9, 2022

Thanks @franck102 for reporting it and yeah this is a know issue, please check #147

Currently you have to @DataSourceMapper("xmlconfig") as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants