• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with null pointer exception in dao layer

 
Greenhorn
Posts: 26
Hibernate jQuery Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic