Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


inject an ejb into jax rs restful service


inject an ejb into jax rs restful service  using -'java,rest,java-ee,ejb,jax-rs'

I'm trying to inject a 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 doing wrong?

Here is some information about my machine:


Glassfish 3.1
Netbeans 6.9 RC 2
Java EE 6


Can you guys show some working example?
    

asked Oct 19, 2015 by 20shahi
0 votes
5 views



Related Hot Questions



Government Jobs Opening


...