This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Spring and JAXWS: No mixing of @Webmethod and @Transactional Annotations allowedPage Title Module

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.

Comment

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.

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.

Comment

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

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.

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.

Comment

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.

No they should not, way in which annotation are defined in Java language spec is one big mess

Class posesses no direct knowledge about annotations that are defined on the implemented interfaces. Sure, it is possible to obtain a list of implemented interfaces (via getIntefaces()), but this should be done not in your code, but in the code that processes annotations, see SPR-2522, SPR-2521 and SPR-2514 for some more discussion.

Comment

Hey all - I ran into this problem too. I got around it by using a @WebService class that implemented the service endpoint interface by forwarding requests to a @Transactional bean that actually did all the work. Then hooked them together using Spring. Effectively it split up the annotations.

Hopefully there's a better solution out there, but for my small project it wasn't a problem...

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.

Comment

Hey all - I ran into this problem too. I got around it by using a @WebService class that implemented the service endpoint interface by forwarding requests to a @Transactional bean that actually did all the work. Then hooked them together using Spring. Effectively it split up the annotations.

Hopefully there's a better solution out there, but for my small project it wasn't a problem...

Hi, we are facing same problem here .. Can you detail out your workaround please..