beginner's ejb deployment question

Discussions

EJB programming & troubleshooting: beginner's ejb deployment question

  1. beginner's ejb deployment question (4 messages)

    I've been writing servlets for a better part of two years, last week I started looking at ejb.

    I have a good idea of how it's supposed to work and have converted one of my simpler servlets to ejb. The problem I'm having is that the client servlet is not able to create an ejb object. I dont get any exceptions, but the lookup call returns a null.

    I'm using jdk 1.4.0, j2ee 1.3.1, resin 2.1.9

    I think it's some sort of a configuration problem in the .ear file, but things look fine to me, I'm using the sun deploy tool.

    thanks for your help

    Threaded Messages (4)

  2. beginner's ejb deployment question[ Go to top ]

    Mike,

       There are few things you might want to check for your problem.

    1. Check your entries in ejb-jar file, make sure that you have proper bean name and same is being used in your code.

    2. For startars you can check documentation on JNDI and make sure you are using proper classes for finding the bean.

    3. Have you generated your bean stub classes ? if you are connecting across the machine, i guess you will need these classes.

    Can you put your code snippet on the board so we can take look at it ?

    Happy working
    Chetan
  3. code[ Go to top ]

    This is the code, I can email you my .ear file if you'll look at it.

    thanx

    mike

    -----

    public class Servlet extends baseServlet{
    ...
    private static ResumeCreatorHome resumeCreatorHome = null;
    public void init(ServletConfig config) throws ServletException {
    ...
    try{
    InitialContext ic = new InitialContext();
    resumeCreatorHome = (ResumeCreatorHome)PortableRemoteObject.narrow(ic.lookup("ResumeCreator"), ResumeCreatorHome.class);
    }catch(Exception e){
    System.err.println("exception occured\nmessage: " + e.getMessage() + "\ncause: " + e.getCause() + "\ntostring: " + e.toString());
    }
    return;
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException{
    ...
    ResumeCreator resumeCreator = null;
    try{
    resumeCreator = resumeCreatorHome.create(); // this throws NullPointerException
    }catch(Exception e){
    System.err.println("exception occured\nmessage: " + e.getMessage() + "\ncause: " + e.getCause() + "\ntostring: " + e.toString());
    }
    ...
    return;
    }
    ...
    }
  4. beginner's ejb deployment question[ Go to top ]

    1. The names match everywhere.
    2. I'm not sure what you mean.
    3. The client servlet and the EJB are in one archive.
  5. beginner's ejb deployment question[ Go to top ]

    mike !!!!!!!!!!

     why do u want your home interface to be static !!!!!!!!!! .... remember that everyting you connect to the container to get the handle for the bean, the container will pickup any bean from the pool and give handle to you. The problem with static is that somehow you want to keep live connection to this bean handle and later keep on using it for some other kind of implementation.
    I will sugget you not to make this stuff static. that will be the first suggestion.