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

EJB injected with @EJB on a RESTFul resource  RSS feed

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

@Path("/customers")
public class CustomerResouce {

@EJB
MyEjb myEjb;

@GET
@Path("{city}")
@Produces("application/xml")
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!