aspose file tools*
The moose likes JSF and the fly likes Getting java.lang.NullPointerException error with (SelectONE) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Getting java.lang.NullPointerException error with (SelectONE)" Watch "Getting java.lang.NullPointerException error with (SelectONE)" New topic
Author

Getting java.lang.NullPointerException error with (SelectONE)

Farhad Rahmati
Ranch Hand

Joined: Dec 16, 2010
Posts: 96
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

Joined: Apr 06, 2010
Posts: 4467
    
    8

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

Joined: Dec 16, 2010
Posts: 96
Thanks for the quick reply,

I think, it should be
as it is null, but I am not sure,
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4467
    
    8

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

Joined: Dec 16, 2010
Posts: 96
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

Joined: Dec 16, 2010
Posts: 96
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

Joined: Apr 06, 2010
Posts: 4467
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting java.lang.NullPointerException error with (SelectONE)