• Post Reply Bookmark Topic Watch Topic
  • New Topic

Spring Dependence Injection in JAX-WS (@WebService) + Tomcat 7 - does not working - returns NPE  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to inject (@Autowired or @Resource) beans created by Spring (3.x or 4.x) in a class that implements a JAX-WS (reference implementation) interface.

Tested and works on Tomcat 6 but in Tomcat 7, it seems that something on the container has changed and the contexts are different.

I have used the proposed integration (which even has bad documentation) as suggested in: http://www.mkyong.com/webservices/jax-ws/jax-ws-spring-integration-example/

In this example, the sun-jaxws.xml file is replaced by a Spring configuration file. However, in my example I'm doing everything with @Configuration because I was trying to avoid XMLs.
I do not know how to make this change to the JAX-WS Endpoint be able to use a bean injected by Spring, without me having to use the applicationContext.getBean ("myBean").

ps.: I have read about every kind of solution, believe me! Some suggest extending SpringBeanAutowiringSupport, others put a @PostConstructor method, but nothing works in Tomcat 7, when I send a SOAP request, my WebService class has no beans in it (NPE).

It is a definition of container? There's no way to do it? That is the main question, so I can give up forever. ;)

Another possible solution: does anyone knows how to do this:

<wss:binding url="/hello">
<ws:service bean="#helloWorldWS"/>

in a java @Configuration class?

Thank you
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!