Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with null pointer exception in dao layer

 
shiva valanukonda
Greenhorn
Posts: 26
Hibernate jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Here is the sample code which is called by some service (myservice)
in Dao class:


in my Action Class:

displaying error msg;

Here, when i call this methos it throwing some null pointer exception. So, complete code is not executing . So, please help me out from this issue.

Thanks & regards
Shiva


 
Jan Cumps
Bartender
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shiva,

can you post the exact error message, and at which line in your code it is thrown?

Also, when posting code, please use the Code button to format it. I have changed the post for you to format the code.
 
T. Huy Nguyen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Your factory, qry, list and list.get(0) may be null and causing NullPointerException. Have you checked each of them?

If you have a proper exception stack trace or error message, identifying the cause will be much faster.
 
R. Grimes
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would change your DAO line from



to



First, you made the mistake of using list.size instead of list.size(). Since the property "size" does not exist, it will throw an error. Only the method size() exists. Second, you should make sure there is something in the list before checking value within it. Thus, I switched your if statement.

Ron
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic