Exception NoClassDefFoundError for CacheProvider Exception NoClassDefFoundError for CacheProvider java java

Exception NoClassDefFoundError for CacheProvider


Change your AnnotationSessionFactoryBean to org.springframework.orm.hibernate4.LocalSessionFactoryBean (Hibernate 4) and you'll be good to go. The AnnotationSessionFactoryBean was replaced with the LocalSessionFactoryBean as it does class path scanning now.


This might be due to changes introduced in Hibernate 4 that are not compatible with Spring support for Hibernate. This issue talks about adding separate package to support hibernate 4. You will need spring 3.1 for this. The other option is to stick to hibernate 3 if you don't need any specific feature introduced in 4.


updating AnnotationSessionFactoryBean to hibernate4 works perfect. Also make sure your transactionManager also points to hibernate4,

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="packagesToScan" value="PACKAGE_NAME"></property> <property name="hibernateProperties">    <props>        <prop key="dialect">org.hibernate.dialect.MySQLDialect</prop>    </props> </property>    </bean><bean id="transactionManager"   class="org.springframework.orm.hibernate4.HibernateTransactionManager">    <property name="sessionFactory" ref="sessionFactory"></property></bean>