Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB injected with @EJB on a RESTFul resource

 
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
 
You've gotta fight it! Don't give in! Read this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!