[SWS-702] sws:annotation-driven does not pick up @Endpoint annotations on classes that are JDK proxies Created: 04/Apr/11  Updated: 04/May/12  Resolved: 18/Oct/11

Status: Closed
Project: Spring Web Services
Component/s: Core
Affects Version/s: 2.0.1
Fix Version/s: 2.0.3

Type: Bug Priority: Critical
Reporter: Erwin Vervaet Assignee: Arjen Poutsma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 4h 20m
Original Estimate: Not Specified
Environment:

SWS 2.0.1.RELEASE



 Description   

We essentially have an app context loaded by the MessageDispatcherServlet that does the following:

<bean id="ws.myWebService" class="foo.bar.MyWebServiceImpl"/>
<aop:aspectj-autoproxy />
<bean class="foo.bar.MyCustomAspect"/>
<sws:annotation-driven/>

The MyWebServiceImpl looks like this:

@Endpoint
public class MyWebServiceImpl implements MyWebService {
 
  @PayloadRoot(namespace = "http://my.foo.bar", localPart = "myWebService")
  @MyCustomAnnotation // picked up by MyCustomAspect to proxy this class
  @ResponsePayload
  public MyResponseDocument getFactInfo(@RequestPayload MyRequestDocument request) {
    ...
  }
}

As a result of the @MyCustomAnnotation, the MyWebServiceImpl will be JDK proxied. Because of this the @Endpoint is not picked up. If we remove the custom aspect the @Endpoint is indeed picked up.

For now, I have added the following to the app context as a workaround:

<aop:config proxy-target-class="true"/>

Note that this seems to be similar to SWS-262



 Comments   
Comment by Arjen Poutsma [ 04/Apr/11 ]

Hey Erwin,

Changing back to unassigned, that's the way I track issues I have to take a look at.

Comment by Arjen Poutsma [ 19/May/11 ]

I can't seem to reproduce this. I have a test case which reproduces this scenario, but it works for me (with or without using CGlib proxies).

See https://src.springframework.org/svn/spring-ws/trunk/core/src/test/java/org/springframework/ws/server/endpoint/mapping/PayloadRootAnnotationMethodEndpointMappingTest.java and the related app context: https://src.springframework.org/svn/spring-ws/trunk/core/src/test/resources/org/springframework/ws/server/endpoint/mapping/applicationContext.xml.

Let me know what I am missing.

Comment by Erwin Vervaet [ 25/May/11 ]

Arjen,

I think you missed the "implements MyWebService" part.
In your test the OtherBean does not implement an interface that defines the "void doIt()" method. As a result JDK proxying is never even considered (it only works with interfaces) and you get the effects of "aop:config proxy-target-class="true"" automatically.

Comment by Arjen Poutsma [ 18/Oct/11 ]

I hope I finally fixed this.

Take a look at https://src.springframework.org/svn/spring-ws/trunk/core/src/test/java/org/springframework/ws/server/endpoint/mapping/JdkProxyRegistrationTest.java and the related app context: https://src.springframework.org/svn/spring-ws/trunk/core/src/test/resources/org/springframework/ws/server/endpoint/mapping/jdk-proxy-registration.xml

Note, however, that the annotations have to be on the interface, and cannot only be on the implementing class. This is due to the fact that the AOP target might change at runtime, and it would be very inefficient to introspect the endpoint each time a web service request comes in. This is consistent with Spring MVC (see SPR-5084).

Comment by Arjen Poutsma [ 04/May/12 ]

Closing old issues

Generated at Fri Dec 15 12:15:57 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.