1 Reply Latest reply on Sep 26, 2010 8:21 PM by 791266

    Getting NullPointerException adding an object to an object array - Help!

      I am working on a webservice where the request can contain a dynamic array of SingleOwnerRequestNodeDetail objects. I need to read these objects in and sort them according to an orderNbr that is contained in the object.
      I am attempting to read these object into a Comparable class and sort them. I am having problems when I try to insert the objects into my object array ComparableBO[]. (See line in bold.) I get the following error: Exception during processing: java.lang.NullPointerException

      Any help here would be appreciated. Thanks!

      Here's my class:

      public class ComparatorBO implements Comparable {

           private SingleOwnerRequestNodeDetail nodeDetailInfo;
           private int orderNbr;
           public SingleOwnerRequestNodeDetail getNodeDetailInfo() {
                return nodeDetailInfo;
           public void setNodeDetailInfo(SingleOwnerRequestNodeDetail nodeDetailInfo) {
                this.nodeDetailInfo = nodeDetailInfo;
           public int getOrderNbr() {
                return Integer.parseInt(nodeDetailInfo.getSingleOwnerRequestOrderNbr());
           public void setOrderNbr (int orderNbr) {
                this.orderNbr = orderNbr;

           public int compareTo(Object anotherNodeDetailInfo)throws ClassCastException {
                if (!(anotherNodeDetailInfo instanceof ComparatorBO))
                     throw new ClassCastException ("An single owner request node detail object is expected");
                int anotherNodeDetailOrderNbr = ((ComparatorBO)anotherNodeDetailInfo).getOrderNbr();
                return this.orderNbr - anotherNodeDetailOrderNbr;

      Here's the code where I read in the objects and attempt to place them in the comparableBO[]

      ComparatorBO[] comparatorBOArray = null;

      comparatorBOArray = new ComparatorBO[requestInfo.length];
                for (int i=0; i < requestInfo.length; i++)
                     SingleOwnerRequestNodeDetail nodes = new SingleOwnerRequestNodeDetail();
                     ComparatorBO comparatorBO = new ComparatorBO();