Reputation: 4805
I am getting following error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDAOImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.quad.dao.RoleDAOImpl.sessionFactory; nested exception is 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 am 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 help .
Upvotes: 0
Views: 6043
Reputation: 1
Whenever you are injecting sessionFactory you must provide its setter and getter methods. it will resolve your problem
Upvotes: 0
Reputation: 842
This is definitely a problem with mismatched dependency versions.
org.hibernate.cache.CacheProvider was removed in Hibernate 4 (a different caching standard was created)
Your session factory class specified is: org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
which is specific to Hibernate 3.
This implies you're using hibernate 4 related dependencies with the wrong session factory class.
As long as you're using Spring 3.1.0.RELEASE or higher, the hibernate 4 classes are available in spring-orm (as are the hibernate3 versions).
You have two options then:
Upvotes: 1