Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.1.Beta2
-
Fix Version/s: None
-
Component/s: Parser
-
Labels:
-
Number of attachments :
Description
In mvel code, when I invoke from org.springframework.web.context.support.XmlWebApplicationContext.getBean(String) method, the actual method invoked is not correct.
The ReflectiveAccessorOptimizer (line 1028) results the cls instance to be the type org.springframework.context.ApplicationContext which is causing the ParseTools.getBestCandidate to find the wrong method.
There are multiple getBean methods in that class and two of them get the same score in getBestCandidate() method:
getBean(String, Object[])
getBean(String)
Since the first one who gets 7 score wins, the candidate is getBean(String, Object[]). But the actual method I invoked is getBean(String). So this cause spring framework throwing exception.
The detail stack trace is below:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Can only specify arguments for the getBean method when referring to a prototype bean definition
at org.springframework.beans.factory.support.AbstractBeanFactory.checkMergedBeanDefinition(AbstractBeanFactory.java:1215) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:278) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:201) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
... 87 common frames omitted
If the class is resolved correctly (XmlWebApplicationContext), then position of the getBean methods will be different and the actual getBean(String) method will appear first and become the right candidate.
This issue will only occur since version 2.0.1.drools8 and up. Earlier version does not have this issue.