Hello
I experience the following error:
java.lang.IllegalStateException: The event listener method class 'tp.system.config.SystemConfig$$EnhancerBySpringCGLIB$$2b9e864_4'
is not an instance of the actual bean class 'tp.system.config.SystemConfig$HOTSWAPAGENT_$$EnhancerBySpringCGLIB$$fddf7a74'.
If the bean requires proxying (e.g. due to @Transactional), please use class-based proxying.
HandlerMethod details:
Bean [tp.system.config.SystemConfig$HOTSWAPAGENT_$$EnhancerBySpringCGLIB$$fddf7a74]
Method [public final void tp.system.config.SystemConfig$$EnhancerBySpringCGLIB$$2b9e864_4.contextRefreshed(org.springframework.context.event.ContextRefreshedEvent)]
Resolved arguments:
[0] [type=org.springframework.context.event.ContextRefreshedEvent] [value=org.springframework.context.event.ContextRefreshedEvent[source=WebApplicationContext
for namespace 'springDispatch-servlet': startup date [Mon Jun 04
13:19:46 CEST 2018]; root of context hierarchy]]
org.springframework.context.event.ApplicationListenerMethodAdapter.assertTargetBean(ApplicationListenerMethodAdapter.java:308)
org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:230)
given is the source:
package tp.system.config
@Configuration
@ComponentScan(basePackages = {
"tp.system",
"front.common"
},
excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Configuration.class)})
@Import({
FileAdapter.class,
FrontConfig.class
})
public class SystemConfig {
@EventListener(ContextRefreshedEvent.class)
public void contextRefreshed(ContextRefreshedEvent event) {
TpValidator validator = new TpValidator();
validator.setApplicationContext(event.getApplicationContext());
validator.validate();
}
}
It
seems like Hotswap has its own bean definition added to the context
(different than Spring's one). When it comes to calling the listener
method contextRefreshed the method is called on behalf of Spring proxy
but gets as an argument the Hotswap bean instance:
return this.bridgedMethod.invoke(bean, args);
I tried to prevent swapping for the package in hotswap-agent.properties:
excludedClassLoaderPatterns=tp.system.config
but with no success.
The only thing that works is a commenting @EventListener method. As I believe SystemConfig than ceases to be a registered as a bean. But it's a target solution.
Any help is appreciated.