Meyyappan has posted 101 posts at DZone. View Full User Profile

Spring Hibernate Integration Tutorial

06.15.2012
| 247137 views |
  • submit to reddit

In this tutorial you will see how to integrate spring and hibernate. I assume you are comfortable with both spring and hibernate. At the end of this example you will learn to create a form, through which you can add a user and list all the existing users as shown below.

 

Here is the directory structure of the example.

 

 You need to have the following lib files in the WEB-INF/lib directory.

antlr-2.7.6
antlr-runtime-3.0
commons-collections-3.1
commons-dbcp
commons-logging-1.0.4
commons-pool
dom4j-1.6.1
ejb3-persistence
hibernate3
hibernate-annotations
hibernate-commons-annotations
hsqldb
javassist-3.4.GA
jstl
jta-1.1
org.springframework.asm-3.0.0.M3
org.springframework.beans-3.0.0.M3
org.springframework.context-3.0.0.M3
org.springframework.context.support-3.0.0.M3
org.springframework.core-3.0.0.M3
org.springframework.expression-3.0.0.M3
org.springframework.jdbc-3.0.0.M3
org.springframework.orm-3.0.0.M3
org.springframework.transaction-3.0.0.M3
org.springframework.web-3.0.0.M3
org.springframework.web.servlet-3.0.0.M3
slf4j-api-1.5.6
slf4j-simple-1.5.6
standard

 The most important part of the example is the spring bean configuration. Here is the spring bean configuration file.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

	<bean id="viewResolver" class="org.springframework.web.servlet.view.
    InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
	
	<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
		<property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/>
		<property name="username" value="sa"/>
		<property name="password" value=""/>
	</bean>
	
	<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.
    annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="myDataSource" />
		<property name="annotatedClasses">
			<list>
				<value>com.vaannila.domain.User</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect"> org.hibernate.dialect.HSQLDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.hbm2ddl.auto">create</prop>
			</props>
		</property>
	</bean>
	
	<bean id="myUserDAO" class="com.vaannila.dao.UserDAOImpl">
		<property name="sessionFactory" ref="mySessionFactory"/>
	</bean>
	
	<bean name="/user/*.htm" class="com.vaannila.web.UserController" >
		<property name="userDAO" ref="myUserDAO" />
	</bean>
	
</beans>

Here we use the Jakarta Commons DBCP BasicDataSource to setup a JDBC DataSource. I am using hsqldb database here, if you are using mysql then you need to change this configuration.

Hibernate SessionFactory can be configured in the spring bean configuration file itself as shown above, you need not have a seperate hibernate configuration file( hibernate.cfg.xml ) to do this. I am using Hibernate annotations in this example, so I am listing all the annotated classes using the annotatedClasses property. All the hibernate related configurations can be done using the hibernateProperties.

We use a seperate DAO class to interact with the database. Using setter injection we inject the Hibernate SessionFactory.

We have a MultiActionController class to handle the web requests, so we use wildcard charcter in the bean name ("/user/*.htm").

Here is the User class with the hibernate annotations, if you want to add any database related constraints, then you need to do it here.

package com.vaannila.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="USER")
public class User {

	private Long id;
	private String name;
	private String password;
	private String gender;
	private String country;
	private String aboutYou;
	private String[] community;
	private Boolean mailingList;
	
	@Id
	@GeneratedValue
	@Column(name="USER_ID")
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name="USER_NAME")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name="USER_PASSWORD")
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	@Column(name="USER_GENDER")
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	
	@Column(name="USER_COUNTRY")
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	
	@Column(name="USER_ABOUT_YOU")
	public String getAboutYou() {
		return aboutYou;
	}
	public void setAboutYou(String aboutYou) {
		this.aboutYou = aboutYou;
	}
	
	@Column(name="USER_COMMUNITY")
	public String[] getCommunity() {
		return cohttp://www.dzone.com/node/add/articlemmunity;
	}
	public void setCommunity(String[] community) {
		this.community = community;
	}
	
	@Column(name="USER_MAILING_LIST")
	public Boolean getMailingList() {
		return mailingList;
	}
	public void setMailingList(Boolean mailingList) {
		this.mailingList = mailingList;
	}

}

 Our DAO class implements the UserDAO interface, here we have just two methods one to save the user details and other to list all the users.

package com.vaannila.dao;

import java.util.List;
import com.vaannila.domain.User;

public interface UserDAO {
	
	public void saveUser(User user) ;
	public List<User> listUser() ;
}

In the DAO class we use Hibernate Template to access the database. To create a Hibernate Template instance, you need a Session Factory, for this purpose we injected the sessionFactory property in the Spring bean configuration file.

package com.vaannila.dao;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;
import com.vaannila.domain.User;

public class UserDAOImpl implements UserDAO {

	private HibernateTemplate hibernateTemplate;

	public void setSessionFactory(SessionFactory sessionFactory) 
    {
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}

	@Override
	public void saveUser(User user) {
		hibernateTemplate.saveOrUpdate(user);
	}

 Hibernate Template is thread safe and reusable. You need not manually open and close Session, Hibernate Template will do that for you.

The UserController class extends MultiActionController class. The UserDAOImpl instance is injected using setter injection. In the add method we call the saveUser() method and redirect the control to the "list.htm" url. This will invoke the list() method. In the list method you add two things to the modelMap, the user list to display the list of users and an instance of the user object to bind the form fields in the userForm.jsp page.

package com.vaannila.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction. MultiActionController;

import com.vaannila.dao.UserDAO;
import com.vaannila.domain.User;

public class UserController extends MultiActionController {

	private UserDAO userDAO;

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

	public ModelAndView add(HttpServletRequest request,
			HttpServletResponse response, User user) throws Exception {
		userDAO.saveUser(user);
		return new ModelAndView("redirect:list.htm");
	}

	public ModelAndView list(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelMap modelMap = new ModelMap();
		modelMap.addAttribute("userList", userDAO.listUser());
		modelMap.addAttribute("user", new User());
		return new ModelAndView("userForm", modelMap);
	}
}

 In the jsp page we use Spring Form tags to display the form fields and jstl tags to display the list of users.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
.even {
	background-color: silver;
}
</style>
<title>Registration Page</title>
</head>
<body>

<form:form action="add.htm" commandName="user">
	<table>
		<tr>
			<td>User Name :</td>
			<td><form:input path="name" /></td>
		</tr>
		<tr>
			<td>Password :</td>
			<td><form:password path="password" /></td>
		</tr>
		<tr>
			<td>Gender :</td>
			<td><form:radiobutton path="gender" value="M" label="M" /> 
            	<form:radiobutton path="gender" value="F" label="F" /></td>
		</tr>
		<tr>
			<td>Country :</td>
			<td><form:select path="country">
				<form:option value="0" label="Select" />
				<form:option value="India" label="India" />
				<form:option value="USA" label="USA" />
				<form:option value="UK" label="UK" />
			</form:select></td>
		</tr>
		<tr>
			<td>About you :</td>
			<td><form:textarea path="aboutYou" /></td>
		</tr>
		<tr>
			<td>Community :</td>
			<td><form:checkbox path="community" value="Spring" label="Spring" />
                <form:checkbox path="community" value="Hibernate" label="Hibernate" />
                <form:checkbox path="community" value="Struts" label="Struts" /></td>
		</tr>
		<tr>
			<td></td>
			<td><form:checkbox path="mailingList"
				label="Would you like to join our mailinglist?" /></td>
		</tr>
		<tr>
			<td colspan="2"><input type="submit" value="Register"></td>
		</tr>
	</table>
</form:form>
<c:if test="${fn:length(userList) > 0}">
	<table cellpadding="5">
		<tr class="even">
			<th>Name</th>
			<th>Gender</th>
			<th>Country</th>
			<th>About You</th>
		</tr>
		<c:forEach items="${userList}" var="user" varStatus="status">
			<tr class="<c:if test="${status.count % 2 == 0}">even</c:if>">
				<td>${user.name}</td>
				<td>${user.gender}</td>
				<td>${user.country}</td>
				<td>${user.aboutYou}</td>
			</tr>
		</c:forEach>
	</table>
</c:if>
</body>
</html>

 Now you can execute the example by running the redirect.jsp page. You will see the following page.

Aftering entering few records you will see the user's list dispalyed below.

You can download and try the example here.

Source :Download

 

 

Published at DZone with permission of its author, Meyyappan Muthuraman.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Mudit Srivastava replied on Tue, 2012/09/25 - 11:09am

I am facing following issue, when tried with above example:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myUserDAO' defined in class path resource [hibernateContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' of bean class [com.poc.met.db.BaseService]: Bean property 'sessionFactory' is not writable or has an invalid setter method. Did you mean 'sessionFactoty'?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
 

Mudit Srivastava replied on Tue, 2012/09/25 - 11:15am in response to: Mudit Srivastava

It was a small spelling mistake.

Instead of setSessionFactory, i wrote setSessionFactoty.

Kishore Kumar replied on Fri, 2012/11/09 - 5:16pm

its very good ya

Narayana Reddy replied on Thu, 2012/11/15 - 1:26pm

 SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
   at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   ... 29 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   ... 35 more
Nov 15, 2012 10:53:26 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
   at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   ... 29 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   ... 35 more
Nov 15, 2012 10:53:26 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /SpringHibernate threw load() exception
java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
   at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Nov 15, 2012 10:53:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9090"]
Nov 15, 2012 10:53:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Nov 15, 2012 10:53:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1168 ms
Nov 15, 2012 10:53:27 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Nov 15, 2012 10:53:27 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'dispatcher': initialization started
Nov 15, 2012 10:53:27 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Nov 15 22:53:27 IST 2012]; root of context hierarchy
Nov 15, 2012 10:53:27 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
Nov 15, 2012 10:53:27 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@717d91: defining beans [viewResolver,myDataSource,mySessionFactory,myUserDAO,/user/*.htm]; root of factory hierarchy
Nov 15, 2012 10:53:27 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@717d91: defining beans [viewResolver,myDataSource,mySessionFactory,myUserDAO,/user/*.htm]; root of factory hierarchy
Nov 15, 2012 10:53:27 PM org.springframework.beans.factory.support.DisposableBeanAdapter invokeCustomDestroyMethod
WARNING: Invocation of destroy method 'close' failed on bean with name 'myDataSource': java.lang.NullPointerException
Nov 15, 2012 10:53:27 PM org.springframework.web.servlet.FrameworkServlet initServletBean
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   ... 33 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   ... 39 more
Nov 15, 2012 10:53:27 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   ... 33 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   ... 39 more
Nov 15, 2012 10:53:27 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet dispatcher
java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)

Narayana Reddy replied on Thu, 2012/11/15 - 1:27pm

 when i run the project i got exception help me

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
   at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   ... 29 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   ... 35 more
Nov 15, 2012 10:53:26 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
   at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   ... 29 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   ... 35 more
Nov 15, 2012 10:53:26 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /SpringHibernate threw load() exception
java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
   at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
   at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Nov 15, 2012 10:53:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9090"]
Nov 15, 2012 10:53:26 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Nov 15, 2012 10:53:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1168 ms
Nov 15, 2012 10:53:27 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Nov 15, 2012 10:53:27 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'dispatcher': initialization started
Nov 15, 2012 10:53:27 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Nov 15 22:53:27 IST 2012]; root of context hierarchy
Nov 15, 2012 10:53:27 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
Nov 15, 2012 10:53:27 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@717d91: defining beans [viewResolver,myDataSource,mySessionFactory,myUserDAO,/user/*.htm]; root of factory hierarchy
Nov 15, 2012 10:53:27 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@717d91: defining beans [viewResolver,myDataSource,mySessionFactory,myUserDAO,/user/*.htm]; root of factory hierarchy
Nov 15, 2012 10:53:27 PM org.springframework.beans.factory.support.DisposableBeanAdapter invokeCustomDestroyMethod
WARNING: Invocation of destroy method 'close' failed on bean with name 'myDataSource': java.lang.NullPointerException
Nov 15, 2012 10:53:27 PM org.springframework.web.servlet.FrameworkServlet initServletBean
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   ... 33 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   ... 39 more
Nov 15, 2012 10:53:27 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/hibernate/MappingException
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   ... 33 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   ... 39 more
Nov 15, 2012 10:53:27 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet dispatcher
java.lang.ClassNotFoundException: org.hibernate.MappingException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:545)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
   at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
   at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
   at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
   at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
   at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)


Mudit Srivastava replied on Fri, 2012/11/16 - 12:57am in response to: Narayana Reddy

 Verify the jar in your classpath for org/hibernate/MappingException

There can be two reasons, either there is no jar or there are more than one jar.

Mudit Srivastava replied on Fri, 2012/11/16 - 12:58am in response to: Narayana Reddy

 Verify the jar in your classpath for org/hibernate/MappingException

There can be two reasons, either there is no jar or there are more than one jar with different versions.

 

James Hake replied on Mon, 2013/04/01 - 10:43pm

Uthra Pattu replied on Fri, 2013/11/08 - 4:51am

where is add.html? i need it

Narayana Reddy replied on Fri, 2013/11/08 - 6:45am in response to: Uthra Pattu

 Here no need of add.html

Prateek Ashtikar replied on Fri, 2013/11/22 - 8:33am in response to: Narayana Reddy

 Hi All,

I'm facing an issue while running this program. Can someone please help me asap, its urgent for me


Hibernate: insert into USER (USER_ABOUT_YOU, USER_COMMUNITY, USER_COUNTRY, USER_GENDER, USER_MAILING_LIST, USER_NAME, USER_PASSWORD) values (?, ?, ?, ?, ?, ?, ?)
Nov 22, 2013 5:55:31 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet dispatcher threw exception
java.sql.SQLException: Data too long for column 'USER_MAILING_LIST' at row 1
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
   at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1812)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1906)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1831)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1693)
   at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
   at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
   at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2345)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2852)
   at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
   at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:320)
   at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:129)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
   at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685)
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677)
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:673)
   at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:740)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
   at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
   at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:737)
   at com.vaannila.dao.UserDAOImpl.saveUser(UserDAOImpl.java:18)
   at com.vaannila.web.UserController.add(UserController.java:23)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)
   at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)
   at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
   at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
   at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Thread.java:619)


Your earliest inputs are much aprreciated....


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.