spring-boot-starter icon indicating copy to clipboard operation
spring-boot-starter copied to clipboard

do not support spring boot 3 native compile?

Open tullyliu opened this issue 2 years ago • 35 comments

using samples code mybatis-spring-boot-samples/mybatis-spring-boot-sample-web mvn -Pnative native:compile

when run target/mybatis-spring-boot-sample-web,it has following exceptions.

java.lang.ExceptionInInitializerError: null
        at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:363) ~[mybatis-spring-boot-sample-web:3.0.0]
        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:745) ~[mybatis-spring-boot-sample-web:6.0.2]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:565) ~[mybatis-spring-boot-sample-web:6.0.2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[mybatis-spring-boot-sample-web:3.0.0]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[mybatis-spring-boot-sample-web:3.0.0]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[mybatis-spring-boot-sample-web:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[mybatis-spring-boot-sample-web:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[mybatis-spring-boot-sample-web:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[mybatis-spring-boot-sample-web:3.0.0]
        at sample.mybatis.web.SampleWebApplication.main(SampleWebApplication.java:25) ~[mybatis-spring-boot-sample-web: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:60) ~[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

tullyliu avatar Dec 15 '22 09:12 tullyliu

So have I. Is there any solution?

Maijh97 avatar Dec 23 '22 09:12 Maijh97

I have the same problem. How to resolve?

Exception in thread "main" org.springframework.boot.context.properties.bind.MissingParametersCompilerArgumentException: Constructor binding in a native image requires compilation with -parameters but the following classes were compiled without it:
        org.apache.ibatis.builder.CacheRefResolver
        org.apache.ibatis.parsing.XNode
        org.apache.ibatis.mapping.ResultFlag
        org.apache.ibatis.builder.ResultMapResolver
        org.apache.ibatis.builder.annotation.MethodResolver

        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar.registerHints(BindableRuntimeHintsRegistrar.java:87)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBeanFactoryInitializationAotProcessor$ConfigurationPropertiesReflectionHintsContribution.applyTo(ConfigurationPropertiesBeanFactoryInitializationAotProcessor.java:70)    
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:78)
        at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
        at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
        at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
        at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
        at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
        at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:76)

gogolin001 avatar Dec 28 '22 10:12 gogolin001

+1

ijry avatar Dec 30 '22 01:12 ijry

Issue is in mybatis core. We will have to release a patch. Will look more at this in coming days... Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg ________________________________ From: jry @.> Sent: Thursday, December 29, 2022 8:50:26 PM To: mybatis/spring-boot-starter @.> Cc: Subscribed @.> Subject: Re: [mybatis/spring-boot-starter] do not support spring boot 3 native compile? (Issue #776) +1 — Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmybatis%2Fspring-boot-starter%2Fissues%2F776%23issuecomment-1367679678&data=05%7C01%7C%7Ca40e3b91e4044529990a08daea083996%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638079618287463263%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gzKzbkpftjjdrDUhwPKaVCAm4FXyW8g1aqPxrP2CCFg%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI7S6H2RBCCFQXAVH7LWPY5WFANCNFSM6AAAAAAS7PY3MI&data=05%7C01%7C%7Ca40e3b91e4044529990a08daea083996%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638079618287463263%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=v6ZbrV3Rnw2bqEVO3%2BtIn1769fK5foq5Uug50AAykLo%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.>

look forward to.

ijry avatar Jan 03 '23 05:01 ijry

Any news on this?

TKorhonen avatar Jan 25 '23 08:01 TKorhonen

I register Slf4jImpl and Marker but still have other error

import org.apache.ibatis.logging.slf4j.Slf4jImpl;
import org.slf4j.Marker;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;

@ImportRuntimeHints(CustomerControllerRuntimeHints.class)
public static class CustomerControllerRuntimeHints implements RuntimeHintsRegistrar {

        @Override
        public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
            hints.reflection().registerType(Slf4jImpl.class, MemberCategory.DECLARED_FIELDS,
                                            MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
                                            MemberCategory.INVOKE_DECLARED_METHODS,
                                            MemberCategory.INVOKE_PUBLIC_METHODS,
                                            MemberCategory.DECLARED_CLASSES);
            hints.reflection().registerType(Marker.class, MemberCategory.DECLARED_FIELDS,
                                            MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
                                            MemberCategory.INVOKE_DECLARED_METHODS,
                                            MemberCategory.INVOKE_PUBLIC_METHODS,
                                            MemberCategory.DECLARED_CLASSES);
        }
    }

but still have ConfigurationClassPostProcessor.init error

duyucongc avatar Feb 19 '23 17:02 duyucongc

I have the same problem. How to resolve?

Exception in thread "main" org.springframework.boot.context.properties.bind.MissingParametersCompilerArgumentException: Constructor binding in a native image requires compilation with -parameters but the following classes were compiled without it: org.apache.ibatis.builder.CacheRefResolver org.apache.ibatis.parsing.XNode org.apache.ibatis.mapping.ResultFlag org.apache.ibatis.builder.ResultMapResolver org.apache.ibatis.builder.annotation.MethodResolver

    at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar.registerHints(BindableRuntimeHintsRegistrar.java:87)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBeanFactoryInitializationAotProcessor$ConfigurationPropertiesReflectionHintsContribution.applyTo(ConfigurationPropertiesBeanFactoryInitializationAotProcessor.java:70)    
    at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:78)
    at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
    at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
    at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
    at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
    at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
    at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
    at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
    at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:76)

Would you like to ask if this problem has been solved?This error also occurred when I used native image packaging in spring boot 3

goatherd-bot avatar Feb 20 '23 06:02 goatherd-bot

Issue is in mybatis core. We will have to release a patch. Will look more at this in coming days... Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg ________________________________ From: jry @.> Sent: Thursday, December 29, 2022 8:50:26 PM To: mybatis/spring-boot-starter @.> Cc: Subscribed @.> Subject: Re: [mybatis/spring-boot-starter] do not support spring boot 3 native compile? (Issue #776) +1 — Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmybatis%2Fspring-boot-starter%2Fissues%2F776%23issuecomment-1367679678&data=05%7C01%7C%7Ca40e3b91e4044529990a08daea083996%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638079618287463263%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gzKzbkpftjjdrDUhwPKaVCAm4FXyW8g1aqPxrP2CCFg%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI7S6H2RBCCFQXAVH7LWPY5WFANCNFSM6AAAAAAS7PY3MI&data=05%7C01%7C%7Ca40e3b91e4044529990a08daea083996%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638079618287463263%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=v6ZbrV3Rnw2bqEVO3%2BtIn1769fK5foq5Uug50AAykLo%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.>

Would you like to ask if this problem has been solved?

goatherd-bot avatar Feb 20 '23 06:02 goatherd-bot

Sorry hasn't been resolved yet. It will be fixed in mybatis 3.5.12. We haven't released it yet.

Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: goatherd-bot @.> Sent: Monday, February 20, 2023 1:35:14 AM To: mybatis/spring-boot-starter @.> Cc: Jeremy Landis @.>; Comment @.> Subject: Re: [mybatis/spring-boot-starter] do not support spring boot 3 native compile? (Issue #776)

Issue is in mybatis core. We will have to release a patch. Will look more at this in coming days... Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysghttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2FAAb9ysg&data=05%7C01%7C%7C466050d8cd3944336dd108db130ca031%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638124717186700764%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TLqVHlWOH9XfPB7Gc4jfLsJxvkbpkOzpvVXwlXhbORQ%3D&reserved=0 … ________________________________ From: jry @.> Sent: Thursday, December 29, 2022 8:50:26 PM To: mybatis/spring-boot-starter @.> Cc: Subscribed @.> Subject: Re: [mybatis/spring-boot-starter] do not support spring boot 3 native compile? (Issue #776https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmybatis%2Fspring-boot-starter%2Fissues%2F776&data=05%7C01%7C%7C466050d8cd3944336dd108db130ca031%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638124717186857001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2jqiCqgLOOW8vfsBisNLeqD5gYbGWmHQ6tLPufBSP70%3D&reserved=0) +1 — Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmybatis%2Fspring-boot-starter%2Fissues%2F776%23issuecomment-1367679678&data=05%7C01%7C%7Ca40e3b91e4044529990a08daea083996%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638079618287463263%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gzKzbkpftjjdrDUhwPKaVCAm4FXyW8g1aqPxrP2CCFg%3D&reserved=0https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmybatis%2Fspring-boot-starter%2Fissues%2F776%23issuecomment-1367679678&data=05%7C01%7C%7C466050d8cd3944336dd108db130ca031%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638124717186857001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TKYRQ39XDzFbwXTWR%2FVQHb5yU%2F9Z7TfW6CVpk5cBXks%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI7S6H2RBCCFQXAVH7LWPY5WFANCNFSM6AAAAAAS7PY3MI&data=05%7C01%7C%7Ca40e3b91e4044529990a08daea083996%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638079618287463263%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=v6ZbrV3Rnw2bqEVO3%2BtIn1769fK5foq5Uug50AAykLo%3D&reserved=0https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI7S6H2RBCCFQXAVH7LWPY5WFANCNFSM6AAAAAAS7PY3MI&data=05%7C01%7C%7C466050d8cd3944336dd108db130ca031%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638124717186857001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MsbhlDYJ0yswz88k5mS81EbMbH4H4t%2BWGYlIqtxeyo4%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.>

Would you like to ask if this problem has been solved?

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmybatis%2Fspring-boot-starter%2Fissues%2F776%23issuecomment-1436406739&data=05%7C01%7C%7C466050d8cd3944336dd108db130ca031%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638124717186857001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TtqtSlIGa8UY0PsJoP7ZQSGnmqCm09OByX7Tpm79N84%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI53XADJGUPOC7WU2NDWYMGCFANCNFSM6AAAAAAS7PY3MI&data=05%7C01%7C%7C466050d8cd3944336dd108db130ca031%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638124717186857001%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=OqgnQ1EtvISG%2B3HrrH3jTX1KAXK2LL38B4SrhTC%2BvdQ%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

hazendaz avatar Feb 20 '23 16:02 hazendaz

When to released? Mybatis is very important.

wghdir avatar Feb 22 '23 08:02 wghdir

going to try for this coming weekend.

hazendaz avatar Feb 22 '23 14:02 hazendaz

is a snapshot version can try?

ijry avatar Mar 03 '23 01:03 ijry

We released 3.5 12 but it has a bad regression. Intended to get it out again tonight but something came up. However expect all of this to be addressed this weekend. Feel free to try the 3.5.12 to just see if the specific issue goes away but know it has issues. See our issue tracker on the core to see the recession. Sorry for the trouble this is otherwise causing.

Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: jry @.> Sent: Thursday, March 2, 2023 8:05:46 PM To: mybatis/spring-boot-starter @.> Cc: Jeremy Landis @.>; Comment @.> Subject: Re: [mybatis/spring-boot-starter] do not support spring boot 3 native compile? (Issue #776)

is a snapshot version can try?

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmybatis%2Fspring-boot-starter%2Fissues%2F776%23issuecomment-1452789205&data=05%7C01%7C%7Ccb25a489ce424642ccfb08db1b836bb7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638134023489160246%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=6aZYDwtUxkXeREDdoKshZJaDt7pTHtgxje2BctPskTg%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI7XQ6YTV6LYAX63E6DW2E7WVANCNFSM6AAAAAAS7PY3MI&data=05%7C01%7C%7Ccb25a489ce424642ccfb08db1b836bb7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638134023489160246%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=7rdtuzJDQ10ZsbVzndgnW3BrEwyxKPCScyImT9rUFZ4%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>

hazendaz avatar Mar 03 '23 05:03 hazendaz

Through ImportRuntimeHints, mybatis use @select("select * from xxxx") can run, but if there is use *Mapper.xml, it will prompt Invalid bound statement (not found).

wghdir avatar Mar 04 '23 08:03 wghdir

is there any solution now?

xiao-er-shang-jiu avatar Mar 26 '23 06:03 xiao-er-shang-jiu

How is this problem progressing now? Do you have any solutions

holmofy avatar Mar 29 '23 08:03 holmofy

mybatis 3.5.13 is out at this point, if you override used version to 3.5.13, I think this will be resolved, can someone confirm?

hazendaz avatar Mar 29 '23 23:03 hazendaz

Hello, I still have the issue with 3.5.13.

Application run failed j.l.NullPointerException: null at o.a.i.l.LogFactory.getLog(LogFactory.java:52) ... 15 common frames omitted Wrapped by: o.a.i.l.LogException: Error creating logger for logger org.mybatis.spring.mapper.ClassPathMapperScanner. Cause: java.lang.NullPointerException at o.a.i.l.LogFactory.getLog(LogFactory.java:54) at o.a.i.l.LogFactory.getLog(LogFactory.java:47) at o.m.l.LoggerFactory.getLogger(LoggerFactory.java:32) at o.m.s.m.ClassPathMapperScanner.(ClassPathMapperScanner.java:61) ... 12 common frames omitted Wrapped by: j.l.ExceptionInInitializerError: null at o.m.s.m.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:363) at o.s.c.s.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:344) at o.s.c.s.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:145) at o.s.c.s.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:747) at o.s.c.s.AbstractApplicationContext.refresh(AbstractApplicationContext.java:565) at o.s.b.w.s.c.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) at o.s.b.SpringApplication.refresh(SpringApplication.java:732) at o.s.b.SpringApplication.refreshContext(SpringApplication.java:434) at o.s.b.SpringApplication.run(SpringApplication.java:310) at o.s.b.SpringApplication.run(SpringApplication.java:1304) at o.s.b.SpringApplication.run(SpringApplication.java:1293) at c.m.m.f.r.Application.main(Application.java:13)

fabienfleureau avatar Mar 30 '23 13:03 fabienfleureau

Hello, I did not find graalvm related file configuration under mybatis3 related library. Has it not yet prepared for compatibility with native?

a483210 avatar Apr 03 '23 01:04 a483210

After using 3.5.13 and running exe after packaging, the following error still occurs If running locally, there is no problem, but there will be an error when running as an exe

` <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> 3.0.0

<groupId>com.XXX.graalvm</groupId>
<artifactId>demo-mybatis</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <java.version>17</java.version>
</properties>
<dependencies>

    <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>3.0.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.5.13</version>
    </dependency>`

@Mapper public interface StoreSceneMapper{ @Select("select * from t_store_scene where scene_id = #{id}") StoreSceneDo getStoreById(@Param(value = "id") String id); }

java.lang.ExceptionInInitializerError: null
        at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:363) ~[demo-mybatis.exe:3.0.1]
        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:745) ~[demo-mybatis.exe:6.0.2]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:565) ~[demo-mybatis.exe:6.0.2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[demo-mybatis.exe:3.0.0]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[demo-mybatis.exe:3.0.0]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[demo-mybatis.exe:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[demo-mybatis.exe:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[demo-mybatis.exe:3.0.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[demo-mybatis.exe:3.0.0]
        at com.jlpay.graalvm.BootstrapApplication.main(BootstrapApplication.java:18) ~[demo-mybatis.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

goatherd-bot avatar Apr 04 '23 02:04 goatherd-bot

If it is solved according to what you said, could you please attach a demo for me to learn how to do it? thank you

goatherd-bot avatar Apr 04 '23 02:04 goatherd-bot

After using 3.5.13 and running exe after packaging, the following error still occurs If running locally, there is no problem, but there will be an error when running as an exe

` org.springframework.boot spring-boot-starter-parent 3.0.0

<groupId>com.XXX.graalvm</groupId>
<artifactId>demo-mybatis</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <java.version>17</java.version>
</properties>
<dependencies>

    <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>3.0.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.5.13</version>
    </dependency>`

@Mapper public interface StoreSceneMapper{ @Select("select * from t_store_scene where scene_id = #{id}") StoreSceneDo getStoreById(@Param(value = "id") String id); }

java.lang.ExceptionInInitializerError: null at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:363) ~[demo-mybatis.exe:3.0.1] 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:745) ~[demo-mybatis.exe:6.0.2] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:565) ~[demo-mybatis.exe:6.0.2] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[demo-mybatis.exe:3.0.0] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[demo-mybatis.exe:3.0.0] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[demo-mybatis.exe:3.0.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[demo-mybatis.exe:3.0.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[demo-mybatis.exe:3.0.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[demo-mybatis.exe:3.0.0] at com.jlpay.graalvm.BootstrapApplication.main(BootstrapApplication.java:18) ~[demo-mybatis.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.(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

I have the same problem. How to resolve?

BlueSkyT avatar Apr 04 '23 09:04 BlueSkyT

Hello,

I tried with a HintsRegistrar inspired from Josh Long blog

import java.util.function.Consumer;
import org.apache.ibatis.javassist.util.proxy.ProxyFactory;
import org.apache.ibatis.javassist.util.proxy.RuntimeSupport;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.logging.log4j.Log4jImpl;
import org.apache.ibatis.logging.log4j2.Log4j2Impl;
import org.apache.ibatis.logging.nologging.NoLoggingImpl;
import org.apache.ibatis.logging.stdout.StdOutImpl;
import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.logging.Logger;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeHint;

public class MyBatisHintsRegistrar implements RuntimeHintsRegistrar {
    @Override
    public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
        Consumer<TypeHint.Builder> memberCategoryBuilder = builder -> builder.withMembers(
                MemberCategory.INVOKE_PUBLIC_METHODS,
                MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
                MemberCategory.PUBLIC_CLASSES,
                MemberCategory.PUBLIC_FIELDS,
                MemberCategory.DECLARED_CLASSES,
                MemberCategory.DECLARED_FIELDS,
                MemberCategory.INTROSPECT_DECLARED_METHODS,
                MemberCategory.INTROSPECT_DECLARED_CONSTRUCTORS
                );
        hints
                .reflection()
                .registerType(MyMapper.class, memberCategoryBuilder)
                .registerType(Logger.class, memberCategoryBuilder)
                .registerType(LogFactory.class, memberCategoryBuilder)
                .registerType(XMLLanguageDriver.class, memberCategoryBuilder)
                .registerType(RuntimeSupport.class, memberCategoryBuilder)
                .registerType(ProxyFactory.class, memberCategoryBuilder)
                .registerType(Log.class, memberCategoryBuilder)
                .registerType(StdOutImpl.class, memberCategoryBuilder)
                .registerType(NoLoggingImpl.class, memberCategoryBuilder)
                .registerType(NoLoggingImpl.class, memberCategoryBuilder)
                .registerType(NoLoggingImpl.class, memberCategoryBuilder)
                .registerType(SqlSessionTemplate.class, memberCategoryBuilder)
                .registerType(SqlSessionFactory.class, memberCategoryBuilder)
                .registerType(SqlSessionFactoryBean.class, memberCategoryBuilder)
                .registerType(Log4jImpl.class, memberCategoryBuilder)
                .registerType(Log4j2Impl.class, memberCategoryBuilder)
                .registerType(org.apache.ibatis.logging.jdk14.Jdk14LoggingImpl.class, memberCategoryBuilder);
        hints
                .proxies()
                .registerJdkProxy(MyMapper.class);
    }
}

and a src/main/resources/META-INF/spring/aot.factories configuration file: org.springframework.aot.hint.RuntimeHintsRegistrar=mypackage.MyBatisHintsRegistrar

With the previous configuration the error disappear but I have another error at during the mapper instanciation: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required"

fabienfleureau avatar Apr 06 '23 22:04 fabienfleureau

Hi, I found a method to generate functional native image, I followed all recomendations but after that I always with the same result. The main problem is the NullpointerException when generate SqlSessionFactory and SqlSessionTemplate because the class LoggerFactory cannot instantiate, I didn't fount the solution for that, I downloaded the source of mybatis starter code and I had to comment the lines of log of the classes:

SqlSessionFactoryBean SqlSessionUtils MyBatisBatchItemWriter ClassPathMapperScanner SpringManagedTransaction

After that I generated a new SNAPSHOT of mybatis starter, I had to create SqlSessionFactory and SqlSessionTemplate in config class and finally I can instantiate a MyBatis Mapper class.

The code is in this repository

https://github.com/cadb-craftsman/springboot-labs.git

https://github.com/cadb-craftsman/springboot-labs/tree/main/catalogsvc

The native image is in docker hub:

https://hub.docker.com/repository/docker/cadbcraftsman/catalogsvc/general

This only works with mybatis annotation classes

cadb-craftsman avatar Apr 14 '23 08:04 cadb-craftsman

I provide a small example for Native image using Spring Boot 3 and MyBatis.

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

We will be support the Spring Native(AOT) on https://github.com/mybatis/spring-native , please wait few time!!

kazuki43zoo avatar May 07 '23 12:05 kazuki43zoo

I added the Quick start page in Wiki

kazuki43zoo avatar May 09 '23 00:05 kazuki43zoo

I provide a small example for Native image using Spring Boot 3 and MyBatis.

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

We will be support the Spring Native(AOT) on https://github.com/mybatis/spring-native , please wait few time!!

It's useful to make my microserivce projects build successfully. The two point I get from this project:

  1. @MapperScan must be declare sqlSessionTemplateRef property;
  2. Copy MyBatisNativeConfiguration into project.

I do appreciate it.

kdldbq avatar Jul 06 '23 09:07 kdldbq

GraalVM Native Image: Generating 'mybatis-native-sample' (executable)...

Warning: Method com.zaxxer.hikari.HikariConfig.getScheduledExecutorService() not found. Warning: Method com.zaxxer.hikari.HikariConfig.isInitializationFailFast() not found. Warning: Method com.zaxxer.hikari.HikariConfig.isJdbc4ConnectionTest() not found. Warning: Method com.zaxxer.hikari.HikariConfig.setInitializationFailFast(boolean) not found. Warning: Method com.zaxxer.hikari.HikariConfig.setJdbc4ConnectionTest(boolean) not found. Warning: Method com.zaxxer.hikari.HikariConfig.setScheduledExecutorService(ScheduledThreadPoolExecutor) not found.

yangmy666 avatar Jul 14 '23 22:07 yangmy666

So what is the current situation of a real Spring native support?

TKorhonen avatar Aug 29 '23 05:08 TKorhonen