Organizational Research By

Surprising Reserch 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 6, 2015 by abhi
0 votes
15 views



Related Hot Questions

7 Answers

0 votes
NULL
answered Oct 6, 2015 by ajit.chavhan
0 votes
NULL
answered Oct 6, 2015 by bhavin
0 votes
NULL
answered Oct 6, 2015 by devkumargupta
0 votes
NULL
answered Oct 6, 2015 by ashish singh
0 votes
NULL
answered Oct 6, 2015 by gauravg.gwl
0 votes
NULL
answered Oct 6, 2015 by sachin wagh
0 votes
NULL
answered Oct 6, 2015 by kotmus2002

...