I want to Inject a EJB
in a jax-rs
class. I get always a NullPointerException
.
Can anybody help me.
The Jax-RS class has following construct:
@Stateless
@Path("uom")
public class RestUOM {
@EJB UOMService memoryService;
@GET
@Path("memory/{hostId}")
@Produces(MediaType.TEXT_XML)
public String checkMemory(@PathParam("hostId") Integer hostId){
Memory memory = this.memoryService.getMemory(hostId); //this.memoryService is null
StringWriter sw = new StringWriter();
JAXB.marshal(memory, sw);
String result = sw.toString();
return result;
}
Why is the local variable memoryService
always null?