Inject a EJB into JAX-RS (RESTfull service)
- by Zeck
Hi guys,
I'm trying to inject Stateless EJB into my JAX-RS webservice via Annotations. Unfortunately the ejb is just null and I get a NullPointerException when I try to use it.
@Path("book")
public class BookResource {
@EJB
private BookEJB bookEJB;
public BookResource() {
}
@GET
@Produces("application/xml")
@Path("/{bookId}")
public Book getBookById(@PathParam("bookId") Integer id)
{
return bookEJB.findById(id);
}
}
What am I wrong doing?
Here are some informations about my machine:
Glassfish 3.1
Netbeans 6.9 RC 2
Java EE 6
Can you guys put some working example? And thank you for every advises and examples?