[jboss-user] [EJB 3.0] - Injecting EJB References NullPointerException JBoss 5.0 in S

mpurdy1973 do-not-reply at jboss.com
Wed Nov 5 16:21:58 EST 2008


When using @EJB for a session bean in a servlet i get a NullPointerException - Am I missing something (new to Jee5 and Injections)

HelloWorldSession  is the interface for HelloWorldSessionBean


  | 
  | public class HelloWorldCallingSessionEJBServlet extends HttpServlet
  | {
  |    @EJB
  |    private HelloWorldSession helloWorldSession;
  |    
  |    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  |    {
  |       this.doWork(request, response);
  |       
  |    }//end method doGet
  |    
  |    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  |    {
  |       this.doWork(request, response);
  |       
  |    }//end method doPost   
  |    
  |    private void doWork(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  |    {
  | ;
  |       String helloString = "empty string";
  |       
  |       helloString = this.helloWorldSession.sayHello();
  |       
  |       response.setContentType("text/html");
  |       PrintWriter out = response.getWriter();
  | 
  |       out.println("<html><head><title>HelloWorld</title></head><body>");
  |       out.println("<h3>" + helloString + "</h3>");
  |       out.println("</body></html>");
  |       
  |       
  |    }//end method doWork
  |    
  |    
  | }//end class HelloWorldCallingSessionEJBServlet
  | 

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

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



More information about the jboss-user mailing list