This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes null pointer exception in spring with hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "null pointer exception in spring with hibernate" Watch "null pointer exception in spring with hibernate" New topic
Author

null pointer exception in spring with hibernate

sanu jony
Greenhorn

Joined: Oct 11, 2004
Posts: 8
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

Joined: Apr 14, 2004
Posts: 10336

Looks like you are trying to use a null object in your DAO. Of course without seeing the code I can't be sure.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
sanu jony
Greenhorn

Joined: Oct 11, 2004
Posts: 8
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
 
subject: null pointer exception in spring with hibernate
 
Similar Threads
unique key hibernate exception
Request processing failed; nested exception is org.springframework.beans.InvalidPropertyException:
Connection to the database Failure
Error Reading data from database
Getting java.lang.NoSuchMethodError