I created my first simple REST-WebService, until now we were only using SOAP based WebServices. Both are in the same package and end up in the same deployment unit.
In the SOAP-WebServices the injection of EJBs works, in the REST-WebService they are not injected ending up in Nullpointer-Exceptions.
Is this expected? What do I have to change to make EJB injection working also for the REST-Webservice?
@Path("/salesOrder")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class SalesOrderRestService
{
private static final Logger LOGGER = Logger.getLogger( SalesOrderRestService.class );
@EJB
private SalesOrder sol;
...
}
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface SalesOrderWSI
{
}
@WebService(endpointInterface = "biz.mbisoftware.fn.ws.sales.SalesOrderWSI", serviceName = "SalesOrderWS")
public class SalesOrderWS implements SalesOrderWSI
{
private static final Logger LOGGER = Logger.getLogger( SalesOrderWS.class );
@EJB
private SalesOrder sol;
...
}
Answering my own question:
to make injection working, the class has to be annotated also with
@Named
@RequestScoped
as it is a simple POJO only without.