facebook

[EJB] Lookup results in null object

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #236036 Reply

    Deddiekoel
    Member

    I’m very new to J2EE. At my course I was advised MyEclipse and after a bit of a rocky start I got my first enterprise application deployed to a Sun App server 8.1.

    Now I’m trying to get a client application to run. I’ve created a new Java project with a normal Java application. I’ve gotton the stubs from the server and included those with the J2EE.jar to the project.
    After that I use the following code:

    try {
    Properties props = new Properties();
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
    “com.sun.jndi.cosnaming.CNCtxFactory”);
    props.setProperty(Context.PROVIDER_URL,
    “iiop://localhost:3700”);
    Context c = new InitialContext(props);
    Object obj = c.lookup(MessengerHome.JNDI_NAME);
    MessengerHome mh =
    (MessengerHome) PortableRemoteObject.narrow(obj, MessengerHome.class);
    System.out.println(mh);
    messenger = mh.create();
    Vector ml = messenger.getMessageList();
    TrackerMessage tm = (TrackerMessage) ml.get(0);
    System.out.println(tm.getContent());
    } catch (Exception e) {
    e.printStackTrace();
    }

    But I get an error on the mh.create() line because mh is null…
    Why is this happening?

    #236062 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft DEv.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: [EJB] Lookup results in null object

You must be logged in to post in the forum log in