cancel
Showing results for 
Search instead for 
Did you mean: 

ArrayList null pointer exception

Former Member
0 Kudos

i get into this problem...

ArrayList detailCol = new ArrayList();

ArrayList col = new ArrayList();

ArrayList ackCol = new ArrayList();

beanCol.add(xxx);

mailSessionBean.insertIntoTable(beanCol, detailCol, ackCol);

when i have the above code....i pass my parameter to insertIntoTable...

i wil get an exception...pls help....

beanCol contains value, detailCol and ackCol doesnt not contains values....

how to initialize the detailCol, ackCol so that it will not throw the NULL POINTER EXCEPTION..........


mailSessionBean.insertIntoTable(beanCol, detailCol, ackCol);


public boolean insertIntoTable(ArrayList beanList, ArrayList detailList, ArrayList ackList){
		boolean insertOk = true;

		System.err.println(new Date() + " In insertIntoTable insertOk=" + insertOk);
		try { 
			System.err.println("check arraylist inmailbean");	
			if(beanList.get(0) instanceof InMailBean){
				InMailBean bean = (InMailBean)beanList.get(0);
				System.err.println("emailId=" +bean.getEmailId());
				System.err.println("ack="+bean.getAckDelivery());
				System.err.println("emailId=" + bean.getEmailId()+ " , ack=" + bean.getAckDelivery() + " , sender=" + bean.getSender()+ " , dateIn=" +  bean.getDateIn() + " receipient=" +  bean.getReceipient()+ " subject=" +  bean.getSubject()+ " , sender=" +  bean.getSender() + " , timeReceive=" + bean.getTimeReceive() + " timein=" +  bean.getTimeIn() + " timeack=" + bean.getTimeAck() + " dateAck=" + bean.getDateAck() + " dateReceive=" + bean.getDateReceive() + " msg:" + bean.getMessage().toString() );
				System.err.println("inMailELocalHome=" + inMailELocalHome);
				InMailELocal inMailELocal = inMailELocalHome.create(bean);
				System.err.println("after insert inMail");
				//insert for Details table
				System.err.println("start to insertinto inmaildet");
				for (Iterator iterator = detailList.iterator(); iterator.hasNext();) {
					InMailDetailsBean detailsBean = (InMailDetailsBean)iterator.next();
					System.err.println("emailId=" + detailsBean.getEmailId() + " , attachmentId=" + detailsBean.getAttachmentId() + " , attachmentName=" + detailsBean.getAttachmentName() +  " , attachment" + detailsBean.getAttachment());
					InMailDetailsELocal inMailDetailsELocal = inMailDetailsELocalHome.create(detailsBean, inMailELocal);
				}
				System.err.println("after insert inMailDetail");	
				 //detailBean = (InMailDetailsBean)detailList.get(0);
				//InMailDetailsELocal inMailDetailsELocal = inMailDetailsELocalHome.create(detailBean,inMailELocal);
			}else if(beanList.get(0) instanceof OutMailBean){
				OutMailBean bean = (OutMailBean)beanList.get(0);
				System.err.println("emailId=" + bean.getEmailId() + " , sender=" + bean.getSender()+ " , dateIn=" +  bean.getDateIn() + " subject=" +  bean.getSubject()+ " , sender=" +  bean.getSender() + " , timeSend=" + bean.getTimeSend() + " timein=" +  bean.getTimeIn() +  " msg:" + bean.getMessage().toString());
				//System.err.println("outMailELocalHome=" + outMailELocalHome);
				OutMailELocal outMailELocal = outMailELocalHome.create(bean);
				System.err.println("after insert outMail");
				// insert for Details table
				if(detailList.size()>0){
					for (Iterator iterator = detailList.iterator(); iterator.hasNext();) {
						OutMailDetailsBean detailsBean = (OutMailDetailsBean)iterator.next();
						System.err.println("AttachmentId=" + detailsBean.getAttachmentId() + " , attachmentName=" + detailsBean.getAttachmentName() + " , attachmentName=" + detailsBean.getAttachment());
						OutMailDetailsELocal outMailDetailsELocal = outMailDetailsELocalHome.create(detailsBean,outMailELocal);
					}
					System.err.println("after insert outMailDetail");
				}
					
				if(ackList.size()> 0){
				  //insert for Ack table
				  for (Iterator iterator = ackList.iterator(); iterator.hasNext();) {
					  OutMailAckBean ackBean = (OutMailAckBean)iterator.next();
					  System.err.println("ackId=" + ackBean.getAckDeliveryId() + " , ack=" + ackBean.getAckDelivery() + " , dateSend=" + ackBean.getDateSend() + " , receipient=" + ackBean.getReceipient() + " , timeSend=" + ackBean.getTimeSend());
					  OutMailAckELocal outMailAckELocal = outMailAckELocalHome.create(ackBean, outMailELocal);;
				  }
				  System.err.println("after insert outMailAck");
					
				}
				
				//OutMailAckBean ackBean = (OutMailAckBean)detailList.get(0);
				//OutMailAckELocal outMailAckELocal = outMailAckELocalHome.create(ackBean, outMailELocal);
			}else if(beanList.get(0) instanceof MailConfigBean){
				MailConfigBean bean = (MailConfigBean)beanList.get(0);
				MailConfigE outMailE = mailConfigEHome.create(bean);
			}
		}catch (CreateException e) {
			insertOk = false;
			System.err.println("CreateException insertOk=" + insertOk);
			System.err.print(new Date() + " " + e.fillInStackTrace());
		} catch (RemoteException e) {
			insertOk = false;
			System.err.println("CreateException insertOk=" + insertOk);
			System.err.print(new Date() + " " + e.fillInStackTrace());
		} 
		
		System.err.println("Final before return insertOk=" + insertOk);
		return insertOk;	
		
	}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Yzme,

try this.

List detailCol = new ArrayList();

List col = new ArrayList();

List ackCol = new ArrayList();

Change also this to:

insertIntoTable(List beanList, List detailList, List ackList){

This should work normally !

regards

G.Werner