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

Update xml sql in mybatis + spring boot project error and will not take effect #550

Closed
wallfacers opened this issue May 10, 2024 · 3 comments

Comments

@wallfacers
Copy link

wallfacers commented May 10, 2024

Environmental Information:
java version: jdk1.8.0_181
dcevm:jdk8u181+2
HotswapAgent:1.4.2-SNAPSHOT

VM options:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
-XXaltjvm=dcevm
-javaagent:D:\develop\java\source\HotswapAgent\hotswap-agent\target\hotswap-agent.jar=propertiesFilePath=D:\downloads\hotswap-agent.properties

operation:
Change what the arrow executes 1 to 2, and then perform hot deployment
image

Error message;
HOTSWAP AGENT: 00:21:00.847 ERROR (org.hotswap.agent.plugin.spring.reload.SpringBeanReload) - Failed to invoke PostProcessorRegistrationDelegate
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.invokePostProcessorRegistrationDelegate(SpringBeanReload.java:666)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.invokeBeanFactoryPostProcessors(SpringBeanReload.java:646)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.doReload(SpringBeanReload.java:296)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.reload(SpringBeanReload.java:259)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.doReload(SpringChangedAgent.java:204)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.reloadAll(SpringChangedAgent.java:192)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.reload(SpringChangedAgent.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hotswap.agent.plugin.spring.reload.SpringChangedReloadCommand.executeCommand(SpringChangedReloadCommand.java:54)
at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:43)
Caused by: java.lang.NullPointerException
at org.mybatis.spring.mapper.MapperScannerConfigurer.processPropertyPlaceHolders(MapperScannerConfigurer.java:386)
at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:354)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:142)
... 17 more

HOTSWAP AGENT: 00:21:00.847 INFO (org.hotswap.agent.plugin.spring.reload.SpringBeanReload) - ##### [1th] finish reloading 'org.springframework.beans.factory.support.DefaultListableBeanFactory@5ef6fd7f', it cost 7ms
HOTSWAP AGENT: 00:21:00.848 ERROR (org.hotswap.agent.plugin.spring.reload.XmlsChangedCommand) - Error invoking method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hotswap.agent.plugin.spring.reload.SpringChangedReloadCommand.executeCommand(SpringChangedReloadCommand.java:54)
at org.hotswap.agent.command.impl.CommandExecutor.run(CommandExecutor.java:43)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.invokeBeanFactoryPostProcessors(SpringBeanReload.java:655)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.doReload(SpringBeanReload.java:296)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.reload(SpringBeanReload.java:259)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.doReload(SpringChangedAgent.java:204)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.reloadAll(SpringChangedAgent.java:192)
at org.hotswap.agent.plugin.spring.reload.SpringChangedAgent.reload(SpringChangedAgent.java:143)
... 6 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.invokePostProcessorRegistrationDelegate(SpringBeanReload.java:666)
at org.hotswap.agent.plugin.spring.reload.SpringBeanReload.invokeBeanFactoryPostProcessors(SpringBeanReload.java:646)
... 11 more
Caused by: java.lang.NullPointerException
at org.mybatis.spring.mapper.MapperScannerConfigurer.processPropertyPlaceHolders(MapperScannerConfigurer.java:386)
at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:354)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:142)
... 17 more

Error cause:
Org. Mybatis. Spring. Mapper. MapperScannerConfigurer creates a temporary DefaultListableBeanFactory for placeholder substitution, And org. Hotswap. Agent. The plugin. Spring. Reload. SpringChangedAgent. SpringChangeAgents cache the temporary DefaultListableBeanFactory, in file change happened, Triggering a reload will cause the newly created bean not to follow the normal spring initialization process
image

Another problem area:
A configuration should be recreated before calling the buildSqlSessionFactory method of the sqlSessionFactoryBean spring bean. Otherwise, the xml file found loaded in the buildSqlSessionFactory method implementation will not be loaded again
image

image

Test case:
https://github.com/wallfacers/hotswap-agent-demo

Related issue:
#538

@wallfacers
Copy link
Author

@skybber help ~

@homejim
Copy link
Contributor

homejim commented Aug 1, 2024

https://github.com/homejim/HotswapAgent/releases/tag/1.4.2.1-SNAPSHOT

This package works correctly and resolves the issue.

@skybber
Copy link
Contributor

skybber commented Aug 3, 2024

@skybber skybber closed this as completed Aug 3, 2024
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

3 participants