spring - Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: sessionFactory -


i getting following error

org.springframework.beans.factory.beancreationexception: error creating bean name 'roledaoimpl': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private org.hibernate.sessionfactory com.quad.dao.roledaoimpl.sessionfactory; nested exception java.lang.noclassdeffounderror: lorg/hibernate/cache/cacheprovider; 

my sessionfactory configuration in mvc-dispatcher-servlet.xml is

<bean id="sessionfactory class="org.springframework.orm.hibernate3.annotation.annotationsessionfactorybean"><property name="datasource" ref="datasource" />    <property name="hibernateproperties">    <props>    <prop key="hibernate.dialect">${hibernate.dialect}</prop>    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>    <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>    </props>    </property>    </bean>   

i using sessionfactory in roledaoimpl

my full mvc-dispatcher-servlet.xml is

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" 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-3.0.xsd     http://www.springframework.org/schema/context      http://www.springframework.org/schema/context/spring-context-3.0.xsd">  <context:component-scan base-package="com.quad.controller" /> <context:component-scan base-package="com.quad.dao" /> <context:component-scan base-package="com.quad.entity" /> <context:component-scan base-package="com.quad.service" />  <context:property-placeholder location="classpath:database.properties" /> <!-- <context:property-placeholder location="classpath:spring-security.xml" />  -->   <bean     class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix">         <value>/web-inf/jsp/</value>     </property>     <property name="suffix">         <value>.jsp</value>     </property> </bean> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource">         <property name="driverclassname" value="${database.driver}" />         <property name="url" value="${database.url}" />         <property name="username" value="${database.user}" />         <property name="password" value="${database.password}" />    </bean>    <bean id="sessionfactory" class="org.springframework.orm.hibernate3.annotation.annotationsessionfactorybean">         <property name="datasource" ref="datasource" />         <property name="hibernateproperties">          <props>           <prop key="hibernate.dialect">${hibernate.dialect}</prop>           <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>           <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>              </props>         </property>   </bean>   

please .

this problem mismatched dependency versions.

org.hibernate.cache.cacheprovider removed in hibernate 4 (a different caching standard created)

your session factory class specified is: org.springframework.orm.hibernate3.annotation.annotationsessionfactorybean

which specific hibernate 3.

this implies you're using hibernate 4 related dependencies wrong session factory class.

as long you're using spring 3.1.0.release or higher, hibernate 4 classes available in spring-orm (as hibernate3 versions).

you have 2 options then:

  1. change hibernate 3
    • this depends on how project built.
    • if it's using maven, involve changing hibernate-core dependencies
  2. change spring configuration hibernate 4
    • this work spring 3.1.0.release or higher
    • for change above mentioned annotationsessionfactorybean to:
      org.springframework.orm.hibernate4.localsessionfactorybean

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -