JBoss 6 + Spring 3.0.5 + JAX-WS / CXF

Our project runs on JBoss 6 with Spring 3.0.5. Everything went smoothly until we tried to implement some web services with JAX-WS. If I try to make some simple WS (for example, adding 2 numbers), it just works - I put annotations and add an annotated class as a servlet. But things get more complicated if I try to make my JAX-WS classes populate with dependencies.

Here is my code:

@WebService(name = "principal")
public class PrincipalWebService extends SpringBeanAutowiringSupport {

    @Autowired
    private PrincipalManager manager;

    @WebMethod
    public int add(int a, int b) {
        return a + b;
    }

    @WebMethod
    public Principal getById(int i) {
            return manager.getById(i);
    }

}

The add method works, but getById does not work with NPE. I was debugging SpringBeanAutowiringSupport and it looks like ContextLoader.getCurrentWebApplicationContext () is returning null. This means that the SpringBeanAutowiringSupport constructor is called before the context is initialized.

CXF Spring. , PrincipalWebService bean, Spring CXF bean ID . Jetty, JBoss. , CXF, - JBoss 6 CXF Spring 2.5, .

- , IoC Jax-ws- JBoss 6?

+2
3

, . , , @PostConstruct:

@PostConstruct
public void init() {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
}
+9

spring jaxws: endpoint bean executor. :

<jaxws:endpoint id="NotificationImpl"
                implementorClass="com.foo.ws.notification.NotificationImpl"
                implementor="#notificationImpl"
                serviceName="notification:Notification"
                address="/notification"
                xmlns:notification="http://notification.ws.foo.com">

:

@Component("notificationImpl")
@WebService(endpointInterface="com.foo.ws.notification.Notification")
public class NotificationImpl implements Notification  {

  @Autowired MessagingService messagingService = null;

  //...
}
+2

All Articles