File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null pointer exception in spring with hibernate

 
sanu jony
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friend,
while i am trying to perform data access by using hibernate in spring frame work i am getting the following exception. my "getHibernateTemplate()" in DAO is passing a null value.
anybody knows the solution for this please help me.


java.lang.NullPointerException
bus.userDAO.saveitem(userDAO.java:34)
bus.PriceIncreaseValidator.validate(PriceIncreaseValidator.java:30)
org.springframework.validation.ValidationUtils.invokeValidator(ValidationUtils.java:49)
org.springframework.web.servlet.mvc.BaseCommandController.bindAndValidate(BaseCommandController.java:260)
org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:235)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:119)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:389)
org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:339)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:325)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you are trying to use a null object in your DAO. Of course without seeing the code I can't be sure.
 
sanu jony
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul Sturrock
this error came while i was trying to insert a value to the table named Item,
my DAO code is given bellow

public class userDAO extends HibernateDaoSupport{
private Item item;
public void setItem(Item item)
{ this.item = item;
System.out.println("<<<<item.getDescription()1>>>");
System.out.println(item.getDescription());
}

public void findGroupByName(String name) {
getHibernateTemplate().save(item);
}
public void saveitem()
{
System.out.println("item.getDescription()200");

System.out.println(getHibernateTemplate());
getHibernateTemplate().save(item);
}

}

here i am getting the item(from POJO) values which i am passing from a jsp page.
but getHibernateTemplate() is returning a null value.
please tell me if u know the solution
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic