and in Bean i have set values as follows .. .. public String ejbCreate (String id, String name, String position, double salary) throws CreateException {
. . now i m cretaing instance in client program as follows .. LocalPlayer ac = (LocalPlayer) PortableRemoteObject.narrow(home.create("nxyz123","xyz","football",500.0), PlayerHome.class); .. and while executing client code i m getting null pointer exception.How can it be solved. Any help will be appreciated. thanks
I just want you to verify that your home object is not null. If it is null, just verify ur jndi url (whether the port mentioned in the webserver layer is the same as that defined in the app server config file.) and also the JNDI name given for that ejb.
If it is not null, we'll consider the other possibilities.
Object home = ctx.lookup(JNDI_NAME); PlayerHome playerHome = (PlayerHome) PortableRemoteObject.narrow(home,PlayerHome.class);
So, can you just tell me where exactly is the null pointer exception. one of your parameter might be null.. The exception should arise on the client side, as there is no remoteexception of anything.
// perform a lookup for the Home
InitialContext context = new InitialContext();
Object homeObject = context.lookup(PLAYERHOMEJNDINAME);
// narrow the jndi reference
PlayerHome home = (PlayerHome) PortableRemoteObject.narrow(homeObject, PlayerHome.class);
// call create. no need to cast or narrow
// by the way: if this is a remote home, how can it
// create local interfaces? Or is "LocalPlayer" just
// someone who plays locally?
LocalPlayer player = home.create("nxyz123","xyz","football",500.0);