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

Support the GraalVM #1552

Open
1 of 7 tasks
kazuki43zoo opened this issue Jun 3, 2019 · 9 comments
Open
1 of 7 tasks

Support the GraalVM #1552

kazuki43zoo opened this issue Jun 3, 2019 · 9 comments
Assignees

Comments

@kazuki43zoo
Copy link
Member

kazuki43zoo commented Jun 3, 2019

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 empty Map instead of Class)

Problems on run-time

  • Not work package scanning (Not found good solution yet)
  • Not work invoke a annotation method(attribute) using reflection (Found solution -> using annotationType() method instead of getClass()) Add constructor that pass an Annotation type instead of Object on ProviderSqlSource #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

kazuki43zoo added a commit to kazuki43zoo/mybatis-3 that referenced this issue Jul 20, 2019
…viderSqlSource

The motivation for this change is to resolve issues that prevent GraalVM support. See mybatisgh-1552
@zhfeng
Copy link

zhfeng commented Jul 30, 2020

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

@linghengqian
Copy link

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?

@zhfeng
Copy link

zhfeng commented Dec 25, 2021

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 !

@ccwxl
Copy link

ccwxl commented Jan 19, 2022

https://github.com/kazuki43zoo/mybatis-spring-native

@kazuki43zoo
Copy link
Member Author

@siaron Thanks for adding link of mybatis-spring-native.

@ccwxl
Copy link

ccwxl commented Jan 20, 2022

@siaron Thanks for adding link of mybatis-spring-native.

The mybatis-plus framework is an extension to myabtis. Consider integration.

@Bahramudin
Copy link

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!

@hazendaz
Copy link
Member

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.

@hazendaz hazendaz self-assigned this Apr 27, 2023
pulllock pushed a commit to pulllock/mybatis-3 that referenced this issue Oct 19, 2023
…viderSqlSource

The motivation for this change is to resolve issues that prevent GraalVM support. See mybatisgh-1552
@xuxiaowei-com-cn
Copy link

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

7 participants