Skip to content

@JmsListener annotated method need to be extracted to interface even if CGLIB used [SPR-16557] #21100

Closed
@spring-projects-issues

Description

@spring-projects-issues

Anton Filatov opened SPR-16557 and commented

Before bugfix #20744 it was impossible to use @JmsListener annotation with cglib-proxied classes at all.
Now it works fine, but stil we need to extract annotated method into interface because processJmsListener try to search invocableMethod as follows

Method invocableMethod = AopUtils.selectInvocableMethod(mostSpecificMethod, bean.getClass());

and this lead to

...
Caused by: java.lang.IllegalStateException: Need to invoke method 'process' declared on target class 'Example', but not found in any interface(s) of the exposed proxy type. Either pull the method up to an interface or switch to CGLIB proxies by enforcing proxy-target-class mode in your configuration.
	at org.springframework.core.MethodIntrospector.selectInvocableMethod(MethodIntrospector.java:135)
	at org.springframework.aop.support.AopUtils.selectInvocableMethod(AopUtils.java:130)
	at org.springframework.jms.annotation.JmsListenerAnnotationBeanPostProcessor.processJmsListener(JmsListenerAnnotationBeanPostProcessor.java:262)
	at org.springframework.jms.annotation.JmsListenerAnnotationBeanPostProcessor.postProcessAfterInitialization(JmsListenerAnnotationBeanPostProcessor.java:240)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
	... 56 common frames omitted

Message is discouraging :)

I suppose that

Method invocableMethod = AopUtils.selectInvocableMethod(mostSpecificMethod, AopUtils.getTargetClass(bean));

will fix this problem.


Affects: 4.3.14

Issue Links:

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions