• Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException with Unkown Source  RSS feed

 
S.Reddisekhar Reddy
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i have code like the below ,when i try to add ItemHistoryEventDetails to ItemHistoryDetails which having the method signature given below ,i am getting
NullPointerException
................................ItemHistoryDetails.setItemHistoryEventDetails(Unknown Source)

method signature--> public void setItemHistoryEventDetails(int arg0, ItemHistoryEventDetails arg1){}

Code-->
ItemHistoryEventDetails itemHistoryEventDetails = new ItemHistoryEventDetails();
itemHistoryEventDetails.setCapitalAmt(new BigDecimal(1234.00));
itemHistoryEventDetails.setCreditPrice(new BigDecimal(1234.00));
ItemHistoryDetails itemHistoryDetails = new ItemHistoryDetails();
itemHistoryDetails.setItemHistoryEventDetails(0,itemHistoryEventDetails);-->RuntimeError


can you please suggest on this
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually the cause of a NullPointerException is invoking a method on a null object. So this means either,

- itemHistoryDetails is null

- itemHistoryEventDetails is null

any of which does not look likely from the code you posted.

Could you post the full method accompanied with the stacktrace, word for word?

Also, please make use the edit button and add code tags to your code; someone whose main forte is the subject of your topic might find it easier to chip in and help you out.
 
S.Reddisekhar Reddy
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i added like ,we have one more method below it is working fine
Signature--> public void setItemHistoryEventDetails(ItemHistoryEventDetails[] arg0)
Code-->
ItemHistoryEventDetails[] item=new ItemHistoryEventDetails[10];
item[0]=itemHistoryEventDetails;
itemHistoryDetails.setItemHistoryEventDetails(item);
 
S.Reddisekhar Reddy
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I concluded that in side setItemHistoryEventDetails(int arg0, ItemHistoryEventDetails arg1){
here they took array and they are added to that
}
so that why we are getting the Error,am i right?
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might be, or might not be. Hard to say at the moment. Probably would help us identify if given an SSCCE form of your code which reproduces the problem.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S.Reddisekhar Reddy wrote: . . . it is working fine . . .
No, isn't. Until you have worked out which reference pointed to null and sorted it out, your code does not work. If that null has not been got rid of, it is only a matter of time before your code crashes again.

Please use the code button. Please don't post such illegible code. If you want any help, please post fuller details, including the stack trace.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!