Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB injected with @EJB on a RESTFul resource  RSS feed

Savio Barros
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that possible use @EJB annotation in a rest resource, which is not a EJB itself? I mean, something like below:

public class CustomerResouce {

MyEjb myEjb;

public List<Customer> getCustomersByCity(@PathParam("city") String city) {
return cityQuery.getResultList(city);


I tried but my EJB always is null. On a JEE7 container (JBoss Wildfly) I could get a valid instance, but on a JEE6, getting null...

Many thanks

Savio Barros
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!