I will propose to support the GraalVM (native-image). I've try to run the demo application using MyBatis 3.5.1 on GraalVM. But I cannot build a native-image using version 3.5.1. I've applied some temporary fix to MyBatis's core components and it worked on GraalVM.
Known mainly problem on core component
Problems on build-time
- [ ] Invoke a default method using reflection (Not found good solution yet)
- [ ] Reflection of Javassist object on instance initialization at
Configuration
(Not found good solution yet) - [ ] Reflection of Class object on static initialization at
SystemMetaObject#NULL_META_OBJECT
(Found solution -> passed the emptyMap
instead ofClass
)
Problems on run-time
- [ ] Not work package scanning (Not found good solution yet)
- [x] Not work invoke a annotation method(attribute) using reflection (Found solution -> using
annotationType()
method instead ofgetClass()
) #1611 - [ ] Not work dynamic class loading (Found solution -> Resolved using native-image building configuration)
- [ ] Not work reflection access to the constructor and method (Found solution -> Resolved using native-image building configuration)
Related Issues and Links
- oracle/graal#1353
- oracle/graal#1108
Comment From: zhfeng
Hi @kazuki43zoo ,
I just find the MethodHandles
which used in MapperProxy is not supported in the GraalVM.
https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md#invokedynamic-bytecode-and-method-handles
Comment From: linghengqian
Hi, I noticed a component like Quarkus MyBatis
in the update log of version 3.5.8 of Mybatis
. Can I understand that Mybatis
under Quarkus
has supported Native Mode ( that is, supports GraalVM
)? Can it be analogized to using Mybatis
on Spring Native
?
Comment From: zhfeng
Hi @linghengqian,
I'm working on Quarkus MyBatis Extension and it supports the native mode by using Graal VM but not all of the mybatis capabities have been test currently. If you are interesting with this project, feel free to use it and any feedback is welcome !
Comment From: ccwxl
https://github.com/kazuki43zoo/mybatis-spring-native
Comment From: kazuki43zoo
@siaron Thanks for adding link of mybatis-spring-native.
Comment From: ccwxl
@siaron Thanks for adding link of mybatis-spring-native.
The mybatis-plus framework is an extension to myabtis. Consider integration.
Comment From: Bahramudin
Hi everyone! Is there any new updates due to MyBatis can be used with GraalVM? I have compiled my Springboot3 (3.0.6) project with MyBatis latest version (3.5.13), but I am getting the below exception while running the generated .exe file:
java.lang.ExceptionInInitializerError: null
at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:363) ~[web.exe:na]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:344) ~[na:na]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:145) ~[na:na]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:747) ~[web.exe:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:565) ~[web.exe:6.0.8]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[web.exe:3.0.6]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[web.exe:3.0.6]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[web.exe:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[web.exe:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[web.exe:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[web.exe:3.0.6]
at com.adil.bms.web.BmsApplication.main(BmsApplication.java:19) ~[web.exe:na]
Caused by: org.apache.ibatis.logging.LogException: Error creating logger for logger org.mybatis.spring.mapper.ClassPathMapperScanner. Cause: java.lang.NullPointerException
at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:54) ~[na:na]
at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:47) ~[na:na]
at org.mybatis.logging.LoggerFactory.getLogger(LoggerFactory.java:32) ~[na:na]
at org.mybatis.spring.mapper.ClassPathMapperScanner.<clinit>(ClassPathMapperScanner.java:61) ~[na:na]
... 12 common frames omitted
Caused by: java.lang.NullPointerException: null
at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:52) ~[na:na]
... 15 common frames omitted
Is there any extra configuration I need to do? Thanks!
Comment From: hazendaz
known issue, will be looking into it as soon as possible. If anyone else knows how to fix, a PR would be great otherwise might be a while.
Comment From: xuxiaowei-com-cn