dev@jersey.java.net

Inject Stateless Bean in jersey web resource

From: Persa Zaloshnja <arushi58_at_hotmail.com>
Date: Thu, 24 Apr 2008 13:33:34 +0200

Hi all,
 
I am creating a stateless bean using EJB3.0 and I'd like to inject that in jersey web resource. If I inject an ejb to an http/sip servlet, it works fine; but when I try the same in a jersey web res, it throws a nullpointer exception. A snippet of code for example:
 
 
@Path("/helloworld")
public class HelloWorldBean {
 
//HERE INJECTING THE BEAN USING ANNOTATIONS.

@EJB(name="ejb/mrbean")
private IMrBean bean;

 
 
@GET
@ProduceMime("text/html")
public String getClichedMessage() {
//WHEN CALL FUNCTION getHello() - NULLPOINTER EXCEPTION THROWN!!!
return bean.getHello();
}
 
(the packaging to deploy in glassfish is done in a .ear - jersey web resource in .war file and ejb in a .jar file)
 
Is there anyone who has tried the same, is it possible to inject 'anything' to a jersey web resource ?
 
 
Thank you in advance,
Farjola
 
 
 
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx