Results 1 to 10 of 18

Thread: Spring and JAXWS: No mixing of @Webmethod and @Transactional Annotations allowed

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    Jena (Germany)
    Posts
    12

    Default Spring and JAXWS: No mixing of @Webmethod and @Transactional Annotations allowed

    Hello,
    we discovered a problem today. We use the Spring integration of the JAX-WS webservice and this was working pretty fine so far.

    An example of how our Webservice looks like can be found here, as it is pretty similar:
    http://www.tutego.com/blog/javainsel/labels/Java.html

    Today we started to add the @Transactional annotations to some methods. Suddenly we got the following exceptions:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating
    bean with name 'jax-ws.http' defined in file
    [C:\Dev\workspace\myProjectDomain\src\web\WEB-INF\myProjectDomain-webServices.xml]:
    Cannot create inner bean 'wss:binding#11c2b67' of type
    [com.sun.xml.ws.transport.http.servlet.SpringBinding] while setting bean
    property 'bindings' with key [0]; nested exception is
    org.springframework.beans.factory.BeanCreationException: Error creating
    bean with name 'wss:binding#11c2b67' defined in file
    [C:\Dev\workspace\myProjectDomain\src\web\WEB-INF\myProjectDomain-webServices.xml]:
    Cannot create inner bean '(inner bean)' of type
    [org.jvnet.jax_ws_commons.spring.SpringService] while setting bean
    property 'service'; nested exception is
    org.springframework.beans.factory.BeanCreationException: Error creating
    bean with name '(inner bean)#1': FactoryBean threw exception on object
    creation; nested exception is java.lang.IllegalArgumentException: class
    de.myCompany.myProject.services.lager.LagerService$$EnhancerByCGLIB$$35598ee0
    has neither @WebSerivce nor @WebServiceProvider annotation
    Caused by: org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'wss:binding#11c2b67' defined in file
    [C:\Dev\workspace\myProjectDomain\src\web\WEB-INF\myProjectDomain-webServices.xml]:
    Cannot create inner bean '(inner bean)' of type
    [org.jvnet.jax_ws_commons.spring.SpringService] while setting bean
    property 'service'; nested exception is
    org.springframework.beans.factory.BeanCreationException: Error creating
    bean with name '(inner bean)#1': FactoryBean threw exception on object
    creation; nested exception is java.lang.IllegalArgumentException: class
    de.myCompany.myProject.services.lager.LagerService$$EnhancerByCGLIB$$35598ee0
    has neither @WebSerivce nor @WebServiceProvider annotation
    Caused by: org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name '(inner bean)#1': FactoryBean threw
    exception on object creation; nested exception is
    java.lang.IllegalArgumentException: class
    de.myCompany.myProject.services.lager.LagerService$$EnhancerByCGLIB$$35598ee0
    has neither @WebSerivce nor @WebServiceProvider annotation
    Caused by: java.lang.IllegalArgumentException: class
    de.myCompany.myProject.services.lager.LagerService$$EnhancerByCGLIB$$35598ee0
    has neither @WebSerivce nor @WebServiceProvider annotation
        at
    com.sun.xml.ws.server.EndpointFactory.verifyImplementorClass(EndpointFactory.java:273)
        at
    org.jvnet.jax_ws_commons.spring.SpringService.getObject(SpringService.java:311)
        at
    org.jvnet.jax_ws_commons.spring.SpringService.getObject(SpringService.java:44)

    I had a look into the sourcecode of the place where the exception is thrown, which can be found here:

    http://fisheye5.cenqua.com/browse/ja...ava?r=1.4#l273

    Code:
    /**
    273 	     * Verifies if the endpoint implementor class has @WebService or @WebServiceProvider
    274 	     * annotation
    275 	     *
    276 	     * @return
    277 	     *       true if it is a Provider or AsyncProvider endpoint
    278 	     *       false otherwise
    279 	     * @throws java.lang.IllegalArgumentException
    280 	     *      If it doesn't have any one of @WebService or @WebServiceProvider
    281 	     *      If it has both @WebService and @WebServiceProvider annotations
    282 	     */
    283 	    public static boolean verifyImplementorClass(Class<?> clz) {
    284 	        WebServiceProvider wsProvider = clz.getAnnotation(WebServiceProvider.class);
    285 	        WebService ws = clz.getAnnotation(WebService.class);
    286 	        if (wsProvider == null && ws == null) {
    287 	            throw new IllegalArgumentException(clz +" has neither @WebSerivce nor @WebServiceProvider annotation");
    288 	        }
    289 	        if (wsProvider != null && ws != null) {
    290 	            throw new IllegalArgumentException(clz +" has both @WebSerivce and @WebServiceProvider annotations");
    291 	        }
    292 	        if (wsProvider != null) {
    293 	            if (Provider.class.isAssignableFrom(clz) || AsyncProvider.class.isAssignableFrom(clz)) {
    294 	                return true;
    295 	            }
    296 	            throw new IllegalArgumentException(clz +" doesn't implement Provider or AsyncProvider interface");
    297 	        }
    298 	        return false;
    299 	    }
    It looks like clz.getAnnotation(WebService.class); doesn't find the right annotation when there are other annotations present.

    After we removed ALL @Transactional annotations it worked pretty fine again. FYI: Annotation driven Transaction handling is properly configured in Spring context and already working in other class which are NO webservices. Only in JAXWS Webservice annotated classes we get these problems.

    We will try now to use Spring's TransactionTemplate to circumvent this problem and get Transaction handling but annotations would be much better.

    Does anybody have an explanation for this problem or a solution?


    Thanks
    Christoph

  2. #2

    Default

    Hi.

    I've got the same problem but with other annotations - not @Transactional but AOP annotations like @Before, @AfterReturning etc.

    Seems this is a problem of the JAX-WS implemenation not able to handle other annotations?

    (How)Did you solve your problem?

  3. #3
    Join Date
    Jun 2006
    Posts
    9

    Default JAXWS Spring @WebService

    Hi ,

    I am experiencing similar issue while using MethodInterceptor for authorization of web services method for Acegi.

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'com.sun.xml
    .ws.transport.http.servlet.SpringBinding' defined in ServletContext resource [/WEB-INF/applicationC
    ontext.xml]: Cannot create inner bean '(inner bean)' while setting bean property 'service'; nested
    exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name
    '(inner bean)': FactoryBean threw exception on object creation; nested exception is java.lang.Ille
    galArgumentException: class CustProdServiceImpl$$EnhancerByCGLIB$
    $e133575d has neither @WebSerivce nor @WebServiceProvider annotation
    Caused by:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean
    )': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentEx
    ception: class CustProdServiceImpl$$EnhancerByCGLIB$$e133575d has
    neither @WebSerivce nor @WebServiceProvider annotation
    Caused by:
    java.lang.IllegalArgumentException: class CustProdServiceImpl$$En
    hancerByCGLIB$$e133575d has neither @WebSerivce nor @WebServiceProvider annotation
    at com.sun.xml.ws.server.EndpointFactory.verifyImplem entorClass(EndpointFactory.java:273)
    at org.jvnet.jax_ws_commons.spring.SpringService.getO bject(SpringService.java:311)
    at org.jvnet.jax_ws_commons.spring.SpringService.getO bject(SpringService.java:44)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getObjectFromFactoryBean(A

    My Class implements an interface still It needs CGLIB, couldnt understand
    Is it something like the the spring web services binding is happening on the generated proxy ??

    Any ideas..

    Thanks

  4. #4

    Default

    Meanwhile I read a bit further about annotations. Seems that per default annotations aren't inherited to subclasses per default. It must be explicitly specified by the annotation itself (e.g. @WebService). Since @WebService doesn't have the @inherited annotation, it won't be inherited to the proxy I guess. So I think it won't be too easy to publish the annotations from the WebService to the proxy. But perhaps I'm totally wrong. I don't know if the proxy could be enhanced to delegate annotation requests to the superclass somehow.

    I think that JAX-WS/jax-ws-commons should be enhanced to look for annotations up the hierarchy if it doesn't find one on the class/identified proxy.

    I created an issue at the jax-ws-commons issue tracker.

    Regards,
    Veit

  5. #5
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    I guess, you may try 2 follwing approaches to overcome this limitation

    1. Try to use CGLIB proxies instead of standard Java proxies. BTW, standard Java proxies proxy not class but interface so even @inherited will not help.
    2. Try to use AspectJ instead of proxy-based AOP.


    Regards,
    Oleksandr

    Quote Originally Posted by vguna View Post
    Meanwhile I read a bit further about annotations. Seems that per default annotations aren't inherited to subclasses per default. It must be explicitly specified by the annotation itself (e.g. @WebService). Since @WebService doesn't have the @inherited annotation, it won't be inherited to the proxy I guess. So I think it won't be too easy to publish the annotations from the WebService to the proxy. But perhaps I'm totally wrong. I don't know if the proxy could be enhanced to delegate annotation requests to the superclass somehow.

    I think that JAX-WS/jax-ws-commons should be enhanced to look for annotations up the hierarchy if it doesn't find one on the class/identified proxy.

    I created an issue at the jax-ws-commons issue tracker.

    Regards,
    Veit

  6. #6

    Default

    Hi Oleksandr.

    Quote Originally Posted by al0 View Post
    I guess, you may try 2 follwing approaches to overcome this limitation

    1. Try to use CGLIB proxies instead of standard Java proxies. BTW, standard Java proxies proxy not class but interface so even @inherited will not help.
    2. Try to use AspectJ instead of proxy-based AOP.


    Regards,
    Oleksandr
    Since my WebService HAS an interface (endpoint interface) with annotations standard JDK proxy should work, shouldn't it?
    Nevertheless I tried CGLIB already - same effect . Thought about using AspectJ as an alternative - not tried yet. Couldn't find anything in google concerning AspectJ and inherited annotations so I hadn't much hope. But I will try it as you suggest. Thanks.

Posting Permissions

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