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?