Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting java.lang.NullPointerException error with (SelectONE)

 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone
I am trying to show data in a SelectOne component. the data is retrived from database base, and everything is perfectly working. the error appears when the following method is invoked.


Anyone got any idea, I would appreciate.
Thanks
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And which line does the exception get thrown on?

Edit: Looking more closely, my guess would be line 3. If it is, it's because supplierSessions hasn't been initialised, so you'd need to look at where that's supposed to happen.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply,

I think, it should be
as it is null, but I am not sure,
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That can't throw an exception. You get a null pointer exception when you try to access something on a null reference, not when you just set a reference to null.

But you say you're not sure? If you've got the stack trace of the exception it will tell you exactly which line it's happening on.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and here is my JSF code, it might help you understand what I am doing,


without the following line, it works, but the drop downlist is empty.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, thank you very much,
I found the line, as you said, Sorry, I am totally new with JEE 6 and JSF

 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, the only way that can throw a null pointer exception is if supplierSessions is null. So probably, either you aren't initialising it anywhere or you are but that code isn't being called for some reason. Either way, it means the actual error isn't in the code you've posted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic