java.lang.NullPointerException in session bean

Hi !

I am trying to get a Entity bean through "LocalHome.findByPrimaryKey".I get an error:java.lang.NullPointerException.

this is session bean:

public class LoginBean implements javax.ejb.SessionBean {

private javax.ejb.SessionContext mySessionCtx;

public UsersLocal usersBean = null;

public List list_app = null,list_userapp = null,list_userappmd = null;

public List list_userapppg = null,list_rol = null,list_rolapp = null;

public UsersLocalHome usersLocalHome = null;

public Hashtable getUsersLocal(String id){

Hashtable usersLocal = null;

UsersLocal usersLocaltmp = null;

UsersKey primarykey = new UsersKey(id);

System.out.println("id="+id);

System.out.println("primarykey="+primarykey.toString());

try {

InitialContext initialContext = new InitialContext();

usersLocalHome = (UsersLocalHome)initialContext.lookup("local:ejb/ejb/pingtai/UsersLocalHome");

System.out.println("usersLocalHome="+usersLocalHome);

try {

usersLocaltmp = usersLocalHome.findByPrimaryKey(primarykey);

usersLocal.put("id",id);

usersLocal.put("mm",usersLocaltmp.getMm());

} catch (FinderException e1) {

}

} catch (NamingException e) {

e.printStackTrace();

}

System.out.println(usersLocal.get("mm"));

return usersLocal;

}

}

Thanks!

[1407 byte] By [jiangzhia] at [2007-11-27 9:30:48]
# 1
What line is the NPE occurring at?
aniseeda at 2007-7-12 22:43:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Hi aniseed !The occurring at "usersLocaltmp = usersLocalHome.findByPrimaryKey(primarykey);"
jiangzhia at 2007-7-12 22:43:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
> Hi aniseed !> The occurring at "usersLocaltmp => usersLocalHome.findByPrimaryKey(primarykey);"I would guess that your lookup for the local home is returning null. Did you check that? If that is the case, you might want to check your JNDI URL.
aniseeda at 2007-7-12 22:43:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
aniseed,thank you very much!now,it's OK! Thank you again!
jiangzhia at 2007-7-12 22:43:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...