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

Incompatible AopNamespaceUtils signature change in Spring 2.5 [SPR-4459] #9137

Closed
spring-issuemaster opened this issue Jan 8, 2008 · 5 comments
Closed
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jan 8, 2008

Cameron Braid opened SPR-4459 and commented

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)


Affects: 2.5 final, 2.5.1

Issue Links:

  • SEC-646 can't get @Secured annotations to work using spring-security in a spring-2.5 app ("is depended on by")

4 votes, 4 watchers

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 17, 2008

Luke Taylor commented

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.

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 17, 2008

Cameron Braid commented

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 ?

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 17, 2008

Cameron Braid commented

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);
}
@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 14, 2008

Juergen Hoeller commented

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

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 14, 2008

Cameron Braid commented

that's great. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.