title: Create bean for sessionFactory in applicaionContext
body: <p><strong>UPDATE: Show full application context</strong></p>
  
  <p>Good day.
  I try to integrate spring and hibernate and tapestry, but have problems with some beans in application-context.xml
  Here my pom.xml part with hibernate and spring.
  I use IDE: Idea 12, with supporting of spring, tapestry and hibernate framework, so some jar file in lib directory. </p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;3.1.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
          &lt;version&gt;3.1.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;2.0.6&lt;/version&gt;
          &lt;/dependency&gt;
  
  
        &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;4.1.2.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;3.1.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>Here my applicationcontext.xml, part for sessionFactry bean </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.xsd"&gt;
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName"&gt;
              &lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="url"&gt;
              &lt;value&gt;jdbc:mysql://localhost:3306/reframework&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="username"&gt;
              &lt;value&gt;root&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="password"&gt;
              &lt;value&gt;root&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="namingStrategy"
            class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"&gt;
          &lt;property name="staticField"&gt;
              &lt;value&gt;org.hibernate.cfg.ImprovedNamingStrategy.INSTANCE&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="namingStrategy"&gt;
              &lt;ref bean="namingStrategy"/&gt;
          &lt;/property&gt;
          &lt;property name="mappingResources"&gt;
              &lt;list&gt;
                  &lt;!--&lt;value&gt;genericdaotest/domain/Person.hbm.xml&lt;/value&gt;--&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLMyISAMDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
          &lt;property name="dataSource"&gt;
              &lt;ref bean="dataSource"/&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager"
            class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="extendedFinderNamingStrategy"
            class="com.packtpub.domain.finder.classes.ExtendedFinderNamingStrategy" /&gt;
  
  
      &lt;!--  Dao Layer generic config--&gt;
      &lt;bean id="finderIntroductionAdvisor" class="com.packtpub.domain.finder.classes.FinderIntroductionAdvisor"/&gt;
      &lt;bean id="abstractDaoTarget"
            class="com.packtpub.domain.dao.ReDAO" abstract="true"&gt;
          &lt;property name="sessionFactory"&gt;
              &lt;ref bean="sessionFactory"/&gt;
          &lt;/property&gt;
          &lt;property name="namingStrategy"&gt;
              &lt;ref bean="extendedFinderNamingStrategy" /&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="abstractDao"
            class="org.springframework.aop.framework.ProxyFactoryBean" abstract="true"&gt;
          &lt;property name="interceptorNames"&gt;
              &lt;list&gt;
                  &lt;value&gt;finderIntroductionAdvisor&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!--  Dao Layer instances --&gt;
      &lt;bean id="objectDao" parent="abstractDao"&gt;
          &lt;property name="proxyInterfaces"&gt;
              &lt;value&gt;com.packtpub.domain.dao.objects.IObjectDAO&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="target"&gt;
              &lt;bean parent="abstractDaoTarget"&gt;
                  &lt;constructor-arg&gt;
                      &lt;value&gt;com.packtpub.domain.entities.ObjectEntity&lt;/value&gt;
                  &lt;/constructor-arg&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>But, when I start my applicationt, it gives me an exception </p>
  
  <pre><code>Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
  </code></pre>
  
  <p>as I understood after searching in hibernate 4 there is no such class, but what I need to do, to solve it?</p>
  
  <p>Here full stacktrace</p>
  
  <pre><code>[DEBUG] AppModule.IObjectService Loading class com.packtpub.services.ObjectService.
  [DEBUG] AppModule.IObjectService Marking class com.packtpub.services.ObjectService to be (re-)loaded
  [DEBUG] AppModule.IObjectService BEGIN Analyzing com.packtpub.services.ObjectService
  [DEBUG] AppModule.IObjectService   END Analyzing com.packtpub.services.ObjectService
  [DEBUG] AppModule.IObjectService Invoking constructor public com.packtpub.services.ObjectService() (for service 'IObjectService')
  [INFO] support.ClassPathXmlApplicationContext Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@5b905255: startup date [Tue Jan 08 21:05:19 MSK 2013]; root of context hierarchy
  [INFO] xml.XmlBeanDefinitionReader Loading XML bean definitions from class path resource [WEB-INF/applicationContext.xml]
  [INFO] support.DefaultListableBeanFactory Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@989472: defining beans [dataSource,namingStrategy,sessionFactory,extendedFinderNamingStrategy,finderIntroductionAdvisor,abstractDaoTarget,abstractDao,objectDao]; root of factory hierarchy
  [INFO] datasource.DriverManagerDataSource Loaded JDBC driver: com.mysql.jdbc.Driver
  [INFO] support.DefaultListableBeanFactory Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@989472: defining beans [dataSource,namingStrategy,sessionFactory,extendedFinderNamingStrategy,finderIntroductionAdvisor,abstractDaoTarget,abstractDao,objectDao]; root of factory hierarchy
  [ERROR] ioc.Registry Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
  [ERROR] ioc.Registry Operations trace:
  [ERROR] ioc.Registry [ 1] Triggering event 'action' on Index:increment
  [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
  org.apache.tapestry5.ioc.internal.OperationException: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider [at classpath:com/packtpub/pages/Index.tml, line 19]
      at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:121)
      at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:88)
      at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
      at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
      at org.apache.tapestry5.internal.structure.ComponentPageElementResourcesImpl.invoke(ComponentPageElementResourcesImpl.java:146)
      at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1053)
      at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:81)
      at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42)
      at $ComponentEventRequestHandler_11e927111127.handle(Unknown Source)
      at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42)
      at $ComponentEventRequestHandler_11e927111127.handle(Unknown Source)
      at org.apache.tapestry5.services.TapestryModule$41.handle(TapestryModule.java:2476)
      at $ComponentEventRequestHandler_11e927111127.handle(Unknown Source)
      at $ComponentEventRequestHandler_11e9271110ae.handle(Unknown Source)
      at org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handleComponentEvent(ComponentRequestHandlerTerminator.java:43)
      at org.apache.tapestry5.services.InitializeActivePageName.handleComponentEvent(InitializeActivePageName.java:39)
      at $ComponentRequestHandler_11e9271110b0.handleComponentEvent(Unknown Source)
      at $ComponentRequestHandler_11e92711107b.handleComponentEvent(Unknown Source)
      at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:46)
      at $Dispatcher_11e92711107e.dispatch(Unknown Source)
      at $Dispatcher_11e927111078.dispatch(Unknown Source)
      at org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:302)
      at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
      at $RequestHandler_11e927111079.service(Unknown Source)
      at org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:902)
      at $RequestHandler_11e927111079.service(Unknown Source)
      at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:892)
      at $RequestHandler_11e927111079.service(Unknown Source)
      at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
      at $RequestHandler_11e927111079.service(Unknown Source)
      at com.packtpub.services.AppModule$1.service(AppModule.java:98)
      at $RequestFilter_11e927111074.service(Unknown Source)
      at $RequestHandler_11e927111079.service(Unknown Source)
      at $RequestHandler_11e92711106d.service(Unknown Source)
      at org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:253)
      at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
      at $HttpServletRequestHandler_11e92711106f.service(Unknown Source)
      at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
      at $HttpServletRequestFilter_11e92711106b.service(Unknown Source)
      at $HttpServletRequestHandler_11e92711106f.service(Unknown Source)
      at org.apache.tapestry5.services.TapestryModule$1.service(TapestryModule.java:852)
      at $HttpServletRequestHandler_11e92711106f.service(Unknown Source)
      at $HttpServletRequestHandler_11e92711106a.service(Unknown Source)
      at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:171)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      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:1004)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
  Caused by: org.apache.tapestry5.runtime.ComponentEventException: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider [at classpath:com/packtpub/pages/Index.tml, line 19]
      at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1136)
      at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$3100(ComponentPageElementImpl.java:61)
      at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1057)
      at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1054)
      at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
      ... 58 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at com.packtpub.services.ObjectService.AddObject(ObjectService.java:27)
      at $IObjectService_11e92711112a.AddObject(Unknown Source)
      at $IObjectService_11e9271110ab.AddObject(Unknown Source)
      at com.packtpub.pages.Index.onActionFromIncrement(Index.java:61)
      at com.packtpub.pages.Index.dispatchComponentEvent(Index.java)
      at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:927)
      at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1112)
      ... 62 more
  Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
      at java.lang.Class.privateGetPublicMethods(Class.java:2562)
      at java.lang.Class.getMethods(Class.java:1427)
      at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1261)
      at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1122)
      at java.beans.Introspector.getBeanInfo(Introspector.java:414)
      at java.beans.Introspector.getBeanInfo(Introspector.java:161)
      at org.springframework.beans.CachedIntrospectionResults.&lt;init&gt;(CachedIntrospectionResults.java:224)
      at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:149)
      at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:324)
      at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:354)
      at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:430)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1362)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
      ... 79 more
  Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.CacheProvider
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
      ... 95 more
  [INFO] AppModule.TimingFilter Request time: 714 ms
  </code></pre>