Skip to content

JDK10 - XML mapper can not be found #1347

@dawwin

Description

@dawwin

I was testing mybatis with JDK10 and I found an issue with named modules. If I want to use xml mapper files then I have to use opens and open mapper package to ALL other modules. Opening for java.base and mybatis doesn't solve the case. It seems like mybatis can't find this file and assumes that it's not there. I tried debugging it, but I ended up in AppClassLoader from java.base which tries to load xml file, but it can't find it. However as I mentioned, adding java.base doesn't help.

MyBatis version

3.4.6, but probably the problem occurs on any version

Database vendor and version

Any

Test case or example project

https://github.com/dawwin/mybatis.jdk10test

Steps to reproduce

Replace opens dwd.mybatisjdk10test.mapper with opens dwd.mybatisjdk10test.mapper to java.base, mybatis; in module-info.java, then run Application.java

Expected result

Successful insert and select calls to database in TestService.runTests(). MyBatis should work with XML files on JDK10 without exposing mapper packages to all other modules.

Actual result

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): dwd.mybatisjdk10test.mapper.UserMapper.saveAll
at [email protected]/org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMethod.java:232) ~[mybatis-3.5.0-SNAPSHOT.jar:na]
at [email protected]/org.apache.ibatis.binding.MapperMethod.(MapperMethod.java:50) ~[mybatis-3.5.0-SNAPSHOT.jar:na]
at [email protected]/org.apache.ibatis.binding.MapperProxy.lambda$cachedMapperMethod$0(MapperProxy.java:62) ~[mybatis-3.5.0-SNAPSHOT.jar:na]
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1719) ~[na:na]
at [email protected]/org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:62) ~[mybatis-3.5.0-SNAPSHOT.jar:na]
at [email protected]/org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:57) ~[mybatis-3.5.0-SNAPSHOT.jar:na]
at jdk.proxy2/com.sun.proxy.jdk.proxy2.$Proxy49.saveAll(Unknown Source) ~[na:na]
at dwd.mybatis.jdk10test/dwd.mybatisjdk10test.service.TestService.runTests(TestService.java:33) ~[classes/:na]

Metadata

Metadata

Assignees

Labels

enhancementImprove a feature or add a new feature

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions