Title: Problems getting sessionbean from servlet

I have been trying to access a SessionBean from a Servlet. I'm running JBOSS 2.0 on Windows NT with Tomcat 3.2.

I have successfully deployed an EAR file containing two servlets and 1 session bean.

One servlet accesses the Oracle DB directly thru an Oracle data source.
The second servlet attempts to call a SessionBean using the same context object that I used to find the data source.

The create() method of my bean actually runs, but when I try to use an instance of the home object in my code I always
get a NullPointer exception whenever I try to do anything with the object

Here is a snippet of code, the stuff for the JNDI lookup is the standard set of JBOSS values, stored as a context param
in my web.xml file. I always get a Null Pointer Exception whenever I try to do anything with the list object.

1) Do I have to do anything special with the JBOSS client classes when my servlet is running inside of JBOSS/Tomcat?
2) Is this related to security?

As best as I can tell the ejbCreate method runs completely.

I'm out of ideas.

Thanks
Dave


   private Hashtable lookup = new Hashtable();
   private Context ctx = null;
   private CourseList list = null;

   //Initialize global variables
  public void init(ServletConfig config) throws ServletException {
      super.init(config);

      ServletContext sctx = config.getServletContext();
      lookup.put(Context.INITIAL_CONTEXT_FACTORY,sctx.getInitParameter(Context.INITIAL_CONTEXT_FACTORY));
      lookup.put(Context.PROVIDER_URL,sctx.getInitParameter(Context.PROVIDER_URL));
      lookup.put(Context.URL_PKG_PREFIXES,sctx.getInitParameter(Context.URL_PKG_PREFIXES));
   }

   //Process the HTTP Get request
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out = new PrintWriter (response.getOutputStream());
      out.println("<html>");
      out.println("<head><title>Course List</title></head>");
      out.println("<body>");

      String offset = (String)request.getParameter("offset");

      try
      {
         if (list == null)
         {
            ctx = new InitialContext(lookup);
            Object ref = ctx.lookup("CourseList");
            CourseListHome listHome = (CourseListHome)PortableRemoteObject.narrow (ref, CourseListHome.class);;
            CourseList list = listHome.create();
         }
         System.out.println(list.getSize());

Reply via email to