Issue Details (XML | Word | Printable)

Key: SPR-4459
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Cameron Braid
Votes: 4
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
Spring Framework

Incompatible AopNamespaceUtils signature change in Spring 2.5

Created: 08/Jan/08 04:56 PM   Updated: 15/Feb/08 07:23 AM   Resolved: 15/Feb/08 05:33 AM
Component/s: SpringAOP
Affects Version/s: 2.5 final, 2.5.1
Fix Version/s: 2.5.2

Time Tracking:
Not Specified

Issue Links:
Depends
 


 Description  « Hide

Caused by: java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Ljava/lang/Object;)V
at org.springframework.security.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:70)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1246)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1236)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:133)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:468)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:363)



Luke Taylor added a comment - 17/Jan/08 08:33 AM

It looks like this is due to a change in the signature of registerAutoProxyCreatorIfNecessary() in Spring 2.5. The second argument is now of type Element rather than an Object.


Cameron Braid added a comment - 18/Jan/08 06:10 AM

The spring-security passes an Element to this method.

Is the solution to add a 'forwards compatible' method signiture to spring-aop-2.0.x ?


Cameron Braid added a comment - 18/Jan/08 07:20 AM

Here's a solution that uses reflection.

I tested this in my app that uses spring-2.5, and it gets past this point.

try {
Method method = AopNamespaceUtils.class.getMethod("registerAutoProxyCreatorIfNecessary",new Class[]{ParserContext.class, Element.class});
try {
method.invoke(null, new Object[] {parserContext, element});
}
catch (java.lang.IllegalAccessException e) { AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element); }
catch (java.lang.reflect.InvocationTargetException e) { AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element); } }
}
catch (NoSuchMethodException e) { AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element); }


Juergen Hoeller added a comment - 15/Feb/08 05:33 AM

I've fixed this through reintroducing the Spring 2.0 registerAutoProxyCreatorIfNecessary and forceAutoProxyCreatorToUseClassProxying signatures in Spring 2.5.2.

So this should work fine now when compiling against Spring 2.0 and running on Spring 2.5. It should also work fine when compiling against Spring 2.5 and explicitly casting the source object to Object for picking the Spring 2.0 compatibility signature (instead of the Element one).

Juergen


Cameron Braid added a comment - 15/Feb/08 05:46 AM

that's great. thanks.