Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null Pointer Exception using DAO, Hibernate and Struts

 
Monica Salvador
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

When I query the Loanapplications from the HQL, it shows a result, but when I use the DAO, it returns a Null Pointer Exception. Please help.




 
Deepakkumar Devarajan
Ranch Hand
Posts: 54
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please post your error message as text and releated code
 
Joe Ess
Bartender
Posts: 9280
10
Linux Mac OS X Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Javaranch.
As Deepakkumar suggests, your error message would be easier to read as text. If you are not going to post all your code, it would be good to indicate which line in your code is the one indicated by the error message.
 
Monica Salvador
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the one that generates the error is the code:

loanapplist = session.createQuery("from Loanapplications").list();

through my further exploration of the error, i have found out that the variable session is null. i used the @SessionTarget annotation though and i am using hibernate. the other DAO's are working fine, but my loanapplicationDAO is not.
 
Monica Salvador
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Deepakkumar Devarajan
Ranch Hand
Posts: 54
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica Salvador wrote:the one that generates the error is the code:
loanapplist = session.createQuery("from Loanapplications").list();


You said in your first post that you are able to query the Loanapplications successfully using HQL but you mentioned the same line causing the issue. Do you mean loanapplist is null even after successful execution of the query??
 
Monica Salvador
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no. the session is null.
 
Manuel Schenkhuizen
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
an easy way to solve your problem.
you can print the elements of your list before return and see what you have got.
i think the problem may be not the nullpoint of you list.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic