Hi,

I am using Jboss 4.0.3, i have developed one simplee ejb application. it is 
successfully deployed. But when i run the application it throws null pointer 
exception. Please see the code, the exception is thrown at the line marked in 
red.

/*
 * SessionTestServlet.java
 *
 */

package test.session;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;

public class SessionTestServlet extends HttpServlet {
  MyTestSessionHome testSessionBean;

  public void init(ServletConfig config) throws ServletException{
  //Look up home interface
   try {
     InitialContext ctx = new InitialContext();
     Object objref = ctx.lookup("ejb/test/MyTestSessionBean");
     testSessionBean = (MyTestSessionHome)PortableRemoteObject.narrow(objref, 
MyTestSessionHome.class);
   } catch (Exception NamingException) {
     NamingException.printStackTrace();
   }


  }

  public void service(HttpServletRequest request, 
     HttpServletResponse response) 
     throws ServletException, IOException
  {

    PrintWriter out;
    response.setContentType("text/html");
    String title = "EJB Example";
    out = response.getWriter();

        out.println("");
        out.println("");
          out.println("Hello World Servlet!");
        out.println("");
        out.println("");
                  out.println("<p align=\"center\"><font size=\"4\" 
color=\"#000080\">Servlet Calling Session Bean");


    try{
    MyTestSession beanRemote;
    System.out.println("Before create");
            beanRemote = testSessionBean.create();     
   System.out.println("After create");
            out.println("<p align=\"center\"> Message from Session Bean is: " + 
beanRemote.SayHi() + "");       
            beanRemote.remove();
    }catch(Exception CreateException){
       CreateException.printStackTrace();
    }
                  out.println("<p align=\"center\"><a 
href=\"javascript:history.back()\">Go to Home");
        out.println("");
        out.println("");


    out.close();
  }

  public void destroy() {
    System.out.println("Destroy");
  }
}




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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4000281
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to