Announcement Announcement Module
Collapse
No announcement yet.
Spring 3.1.0.RC1 and Hibernate 4.0.0.CR6: NoClassDefFoundError on CacheProvider Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3.1.0.RC1 and Hibernate 4.0.0.CR6: NoClassDefFoundError on CacheProvider

    I'm trying to upgrade a webapp from Spring 3.0.6.RELEASE and Hibernate 3.6.8.Final to Spring 3.1.0.RC1 and Hibernate 4.0.0.CR6.

    Now I get a NoClassDefFoundError on org.hibernate.cache.CacheProvider:

    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory no.uio.webapps.minestudiermed.dao.GenericDAOImpl.sessionFactory; nested exception is java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider;
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)

    I have to following config:

    Code:
       <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
          <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
          <property name="dataSource" ref="dataSource"/>
          <property name="hibernateProperties" ref="hibernateProperties"/>
          <property name="packagesToScan">
             <list>
                <value>com.me.myapp.domain</value>
             </list>
          </property>
       </bean>
    Code:
                <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernateEhCacheProvider</prop>
                <prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory</prop>

    TIA!


    -Kaj

  • #2
    Well how about not using the hibernate3 configuration classes with hibernate4..... Also the cache solution you use is for hibernate3 not for 4.

    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
          <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
          <property name="dataSource" ref="dataSource"/>
          <property name="hibernateProperties" ref="hibernateProperties"/>
          <property name="packagesToScan">
             <list>
                <value>com.me.myapp.domain</value>
             </list>
          </property>
       </bean>

    Comment


    • #3
      Thanks for answering!

      I now got this working. I found some usefull tips on http://code.google.com/p/jgk-spring-...g31_Hibernate4


      -Kaj

      Comment

      Working...
      X