Results 1 to 7 of 7

Thread: jax-ws WebService not getting proxied

  1. #1
    Join Date
    Dec 2007
    Posts
    6

    Default jax-ws WebService not getting proxied

    Hi !

    I've created a log aspect to log enter and exit for all public methods in my web service project, as well as handling exceptions. It works fine for the classes managed directly by spring.
    My web service class, however, is managed by the websphere jax-ws runtime and cannot be added to the spring config file. To be able to inject dependencies on it, I 've made it extend SpringBeanAutowiringSupport.
    The autowiring of dependencies works fine, but the class doesn't get proxied.

    Is this expected behaviour? If so, is it possible to proxy a websphere-managed bean so that my logging functionality will apply to it?

    Thanks in advance!

    Package name for web service class: no.klp.webservice.aspects
    Aspect configuration:
    Code:
    <aop:config>
    <aop:pointcut id="allPublicOperations"
    	expression="execution(* no.klp.ecm..*.*(..))" />								  
    <aop:aspect id="logCorrelationId" ref="logCorrelationIdBean">
    	<aop:around pointcut-ref="allPublicOperations" method="logCorrelationId" />
    </aop:aspect>
    <aop:aspect id="afterThrowing" ref="logCorrelationIdBean">
    
    	<aop:after-throwing pointcut-ref="allPublicOperations" throwing="exception"
    		method="logCorrelationIdAfterThrowing" />
    </aop:aspect>
    </aop:config>

  2. #2
    Join Date
    Jun 2009
    Posts
    190

    Default

    Beans need to be spring managed.

    -Hetal

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Spring can and will only proxy beans it knows about, ie beans which are configured in the application context. Your jax-ws based service isn't part of that.

    If you want more power use something like AspectJ and apply load or compile time weaving to achieve what you want.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4
    Join Date
    Dec 2007
    Posts
    6

    Default

    Thanks for the replies!
    Your answers seems reasonable, however another question arises. As mentioned, my services has @Autowired annotations on them, and my config file contains the annotation-config instruction. I guess this means they are implicitly added to the application context. Isn't this "good enough" for the <aop:config> to find it?

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Your jax-ws webservice still remains outside of the scope of spring. The fact that @Autowired works doesn't make it a spring managed bean, the SpringBeanAutowiringSupport makes that work with a little trickery, but it remains a unmanaged bean.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #6
    Join Date
    Dec 2007
    Posts
    6

    Default

    Ok. Thanks!
    I had a look at the SpringBeanAutowiringSupport actually only processes injections, it doesn't seem to register anything in the application context.

    Then the workaround is just to keep the service class ultra thin, and make spring managed delegates do the actual work.

  7. #7
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Then the workaround is just to keep the service class ultra thin, and make spring managed delegates do the actual work.
    IMHO that is always the recommended way, your logic should be in the services/domain layer. Your web/web service/other connections should be as thin as possible just do mapping and call the appropriate methods.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •