Timoteo Ponce
Timoteo Ponce

Reputation: 510

Java EE 6 WebService and CDI injection

This is a clarification question I've got from a Java EE 5 migration. I'm currently developing a Java EE 6 web service packed in a WAR file, and I would like to know if it's possible to use CDI on it. I've seen some examples using the @Stateless annotation, which it's not possible to do in a WAR (as far as I know).

Current implementation:

@WebService
public class MyService{

    @Inject 
    HelloTeller teller:

    @WebMethod
    public String sayHello(){
        teller.sayHello();
    }
}

Note: The other approach would be to create an ejbModule specifically for this web-service.

Upvotes: 1

Views: 3065

Answers (1)

LightGuard
LightGuard

Reputation: 5378

In EE6, you should be able to use a SLSB as JAX-WS endpoint in a war. You can inject EJBs, request scoped and application scoped beans from CDI.

Upvotes: 2

Related Questions