File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes java.lang.NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "java.lang.NullPointerException" Watch "java.lang.NullPointerException" New topic
Author

java.lang.NullPointerException

rohit aggarwal
Greenhorn

Joined: Jul 11, 2001
Posts: 21
i am getting this error:
java.lang.Exception: Errror in processRequest(): java.lang.Exception: categoryRemote = categoryHome.create() java.lang.NullPointerException
i am calling CategoryEJB.java through CategoryBean.java in jsp page.
CategoryBean.java is
/*
Page Name :-CategoryBean.java
Author(s) :-Rohit Aggarwal
Description of Page:-Acts as interface between auc_sell_product.jsp and CategoryEJB.java
Previous Page(s):-
Next Page(s):-
Date of Creation:-25/07/2001
Date of Last Modification :-25/07/2001
*/
package javaBeans;
import java.util.*;
import ejbBeans.*;
import java.io.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class CategoryBean
{
privateCollection categoryID ;
privateCollection categoryName ;
private String catstrname;
private String catstrid;
private CategoryHome catHome;
private CategoryRemote catRemote;
private String statefull;

public CategoryBean()
{
try
{
Context ic = new InitialContext();
java.lang.Object objref = ic.lookup("java:comp/env/ejb/Category");
catHome = (CategoryHome) PortableRemoteObject.narrow(objref,ejbBeans.CategoryHome.class);
}
catch (Exception re)
{
System.out.println ("Couldn't locate Category Home.Error CategoryBean.java");
re.printStackTrace();
}

}
public Collection getCategoryID()
{
return categoryID;
}

public Collection getCategoryName()
{
return categoryName;
}
public void setCatStrID(String id)
{
this.catstrid=id;
}
public void setCatStrName(String name)
{
this.catstrname=name;
}

public String getCatStrName()
{
return catstrname;
}
public String getCatStrID()
{
return catstrid;
}
public void setCategoryID(Collection id)
{
this.categoryID=id;
}

public void setCategoryName(Collection catname)
{
this.categoryName=catname;
}

public void processCategoryRequest() throws Exception
{
try
{
System.out.println("start processCategoryRequest");
statefull="no";
catRemote=catHome.create(statefull);
}
catch (Exception e)
{
throw new Exception("categoryRemote=categoryHome.create() "+e);//getting null pointer exception here
}

try
{
System.out.println("start loadfromejb");
loadFromCategoryEJB();
System.out.println("end of load from Categoryejb");
}
catch (Exception e)
{
throw new Exception("Errror in processCategoryRequest() while loadingFromCategoryEJB(): "+e);
}
} // try
catch (Exception e)
{
throw new Exception("Errror in processRequest(): "+e);
}

}
private void loadFromCategoryEJB() throws Exception
{
try
{
System.out.println("in loadfromejb");
setCatStrID(catRemote.getCatStrID());
setCatStrName(catRemote.getCatStrName());
setCategoryID(catRemote.getCategoryID());
setCategoryName(catRemote.getCategoryName());
}
catch (Exception re)
{
throw new Exception("Errror in loadFromEJB(): "+re);
}
}
}

[This message has been edited by rohit aggarwal (edited August 16, 2001).]
rohit aggarwal
Greenhorn

Joined: Jul 11, 2001
Posts: 21
i am guessing that home object is not getting initialized.
why??
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.lang.NullPointerException
 
Similar Threads
Maintain checked checkbox status
Parent Key Not Found Error
proble in converting ArrayList<String> to ArrayList<Object>
java.lang.ClassCastException for cmp entity beans
help me in this JSP checkbox code