Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-702

sws:annotation-driven does not pick up @Endpoint annotations on classes that are JDK proxies

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.3
    • Component/s: Core
    • Labels:
      None
    • 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

        Activity

        klr8 Erwin Vervaet created issue -
        klr8 Erwin Vervaet made changes -
        Field Original Value New Value
        Assignee Arjen Poutsma [ arjen.poutsma ]
        klr8 Erwin Vervaet made changes -
        Component/s Core [ 10150 ]
        Affects Version/s 2.0.1 [ 11810 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Hey Erwin,

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

        Show
        arjen.poutsma Arjen Poutsma added a comment - Hey Erwin, Changing back to unassigned, that's the way I track issues I have to take a look at.
        arjen.poutsma Arjen Poutsma made changes -
        Assignee Arjen Poutsma [ arjen.poutsma ]
        arjen.poutsma Arjen Poutsma made changes -
        Fix Version/s 2.0.2 [ 11893 ]
        Assignee Arjen Poutsma [ arjen.poutsma ]
        arjen.poutsma Arjen Poutsma made changes -
        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 proxies. 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
        We essentially have an app context loaded by the MessageDispatcherServlet that does the following:

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

        The MyWebServiceImpl looks like this:

        {code}
        @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) {
            ...
          }
        }
        {code}

        As a result of the @MyCustomAnnotation, the MyWebServiceImpl will be JDK proxies. 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:
        {code:xml}
        <aop:config proxy-target-class="true"/>
        {code}

        Note that this seems to be similar to SWS-262
        arjen.poutsma Arjen Poutsma made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -
        Show
        arjen.poutsma Arjen Poutsma added a comment - 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.
        arjen.poutsma Arjen Poutsma made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Cannot Reproduce [ 5 ]
        arjen.poutsma Arjen Poutsma logged work - 19/May/11 5:55 AM
        • Time Spent:
          17m
           
          <No comment>
        arjen.poutsma Arjen Poutsma made changes -
        Time Spent 17m [ 1020 ]
        Worklog Id 28122 [ 28122 ]
        Remaining Estimate 0d [ 0 ]
        klr8 Erwin Vervaet made changes -
        Description We essentially have an app context loaded by the MessageDispatcherServlet that does the following:

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

        The MyWebServiceImpl looks like this:

        {code}
        @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) {
            ...
          }
        }
        {code}

        As a result of the @MyCustomAnnotation, the MyWebServiceImpl will be JDK proxies. 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:
        {code:xml}
        <aop:config proxy-target-class="true"/>
        {code}

        Note that this seems to be similar to SWS-262
        We essentially have an app context loaded by the MessageDispatcherServlet that does the following:

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

        The MyWebServiceImpl looks like this:

        {code}
        @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) {
            ...
          }
        }
        {code}

        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:
        {code:xml}
        <aop:config proxy-target-class="true"/>
        {code}

        Note that this seems to be similar to SWS-262
        Hide
        klr8 Erwin Vervaet added a comment -

        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.

        Show
        klr8 Erwin Vervaet added a comment - 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.
        klr8 Erwin Vervaet made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Cannot Reproduce [ 5 ]
        arjen.poutsma Arjen Poutsma made changes -
        Fix Version/s 2.0.2 [ 11893 ]
        Fix Version/s 2.0.3 [ 12197 ]
        arjen.poutsma Arjen Poutsma made changes -
        Status Reopened [ 4 ] In Progress [ 3 ]
        arjen.poutsma Arjen Poutsma logged work - 18/Oct/11 4:14 AM
        • Time Spent:
          4.05h
           
          <No comment>
        arjen.poutsma Arjen Poutsma made changes -
        Worklog Id 28437 [ 28437 ]
        Time Spent 17m [ 1020 ] 4h 20m [ 15600 ]
        arjen.poutsma Arjen Poutsma made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        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).

        Show
        arjen.poutsma Arjen Poutsma added a comment - 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 ).
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Closing old issues

        Show
        arjen.poutsma Arjen Poutsma added a comment - Closing old issues
        arjen.poutsma Arjen Poutsma made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        45d 17m 1 Arjen Poutsma 19/May/11 5:38 AM
        Resolved Resolved Reopened Reopened
        6d 17h 30m 1 Erwin Vervaet 25/May/11 11:25 PM
        Reopened Reopened In Progress In Progress
        145d 2h 45m 1 Arjen Poutsma 18/Oct/11 2:10 AM
        In Progress In Progress Resolved Resolved
        2h 20m 2 Arjen Poutsma 18/Oct/11 4:14 AM
        Resolved Resolved Closed Closed
        199d 2h 48m 1 Arjen Poutsma 04/May/12 7:03 AM

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            klr8 Erwin Vervaet
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0d
              0d
              Logged:
              Time Spent - 4h 20m
              4h 20m