title: org.springframework.beans.factory.BeanCreationException in struts spring hibernate example
body: <p>I am trying to run spring struts and hibernate example in tomcat6 , i am getting following error.</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/config/database/spring/HibernateSessionFactory.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: entity class not found: com.mkyong.customer.model.Customer
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
      at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicationContext(ContextLoaderPlugIn.java:354)
      at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplicationContext(ContextLoaderPlugIn.java:295)
      at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoaderPlugIn.java:225)
      at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:871)
      at org.apache.struts.action.ActionServlet.init(ActionServlet.java:359)
      at javax.servlet.GenericServlet.init(GenericServlet.java:212)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
  </code></pre>
  
  <p>HibernateSessionFactory.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;
  
  &lt;!-- Hibernate session factory --&gt;
  
      &lt;bean id="sessionFactory" 
           class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
  
          &lt;property name="dataSource"&gt;
            &lt;ref bean="dataSource"/&gt;
          &lt;/property&gt;
  
          &lt;property name="hibernateProperties"&gt;
             &lt;props&gt;
               &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
               &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
             &lt;/props&gt;
          &lt;/property&gt;
  
          &lt;property name="mappingResources"&gt;
              &lt;list&gt;
                     &lt;value&gt;com/mkyong/customer/hibernate/Customer.hbm.xml&lt;/value&gt;
              &lt;/list&gt;
           &lt;/property&gt;    
  
      &lt;/bean&gt;
      &lt;/beans&gt;
  </code></pre>
  
  <p>Customer.hbm.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  &lt;!-- Generated 20 April 2010 8:33:09 PM by Hibernate Tools 3.2.5.Beta --&gt;
  &lt;hibernate-mapping&gt;
      &lt;class name="com.mkyong.customer.model.Customer" table="customer" catalog="mkyong"&gt;
          &lt;id name="customerId" type="long"&gt;
              &lt;column name="CUSTOMER_ID" /&gt;
              &lt;generator class="identity" /&gt;
          &lt;/id&gt;
          &lt;property name="name" type="string"&gt;
              &lt;column name="NAME" length="45" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;property name="address" type="string"&gt;
              &lt;column name="ADDRESS" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;property name="createdDate" type="timestamp"&gt;
              &lt;column name="CREATED_DATE" length="19" not-null="true" /&gt;
          &lt;/property&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>SpringBeans.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;
  
      &lt;!-- Database Configuration --&gt;
      &lt;import resource="config/database/spring/DataSource.xml"/&gt;
      &lt;import resource="config/database/spring/HibernateSessionFactory.xml"/&gt;
  
      &lt;!-- Beans Declaration --&gt;
      &lt;import resource="com/mkyong/customer/spring/CustomerBean.xml"/&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Directory Structure for Customer.java</p>
  
  <pre><code>StrutsSpringExample
      src/main/java
          com.mkyong.customer
              model
                Customer.java
  </code></pre>
  
  <p>Package for Customer.java</p>
  
  <pre><code>com.mkyong.customer.model
  </code></pre>