[jboss-user] [EJB 3.0] - @EJB Supported???

itty06 do-not-reply at jboss.com
Fri Nov 17 05:51:25 EST 2006


http://docs.jboss.org/ejb3/app-server/tutorial/ear/ear.html
@EJB annotations are usable in servlets and JSPs, but unfortunately, we have not yet updated tomcat to support it. Also, Tomcat works with the old XML format so you cannot use XML either. So for now, you must lookup the EJB via its global JNDI name. This is not compliant, but if you abstract out enough you'll be fine. 

  | 
  | 
  |    public void init() throws ServletException
  |    {
  |       super.init();
  |       try
  |       {
  |          InitialContext ctx = new InitialContext();
  | 
  |          // J2EE 1.5 has not yet defined exact XML <ejb-ref> syntax for EJB3
  |          CalculatorLocal calculator = (CalculatorLocal) ctx.lookup("tutorial/CalculatorBean/local");
  |          setCalculator(calculator);
  |       }
  |       catch (NamingException e)
  |       {
  |          throw new RuntimeException(e);
  |       }
  | 
  |    }
  | 
  | 
  | 
The tutorial says it is possible but tomcat has not been updated to support it. 

does that mean
@EJB private HelloLocal hello;
won't inject bean instance?

I tried it and I didn't see the difference, it works fine in EJB or Servlet.

Can someone explain what if it is different to what I am understanding.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986791#3986791

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986791



More information about the jboss-user mailing list