1 Reply Latest reply on Nov 26, 2011 2:26 PM by Adam Warski

    Unable to configure Envers

    Deepali Bhandari Newbie

      So we have a Spring file so, we are using Hibernate-3.5.5

      <bean id="sessionFactory"

        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

        <property name="namingStrategy">

         <ref bean="namingStrategy" />

        </property>

        <property name="mappingResources">

         <list>

            

          <value>Run.hbm.xml

          </value>

         

         </list>

        </property>

        <property name="hibernateProperties">

         <props>

          <prop key="hibernate.dialect">${dialect}</prop>

          <prop key="hibernate.cache.provider_class">

           <!--  org.hibernate.cache.ehcacheprovider-->

           net.sf.ehcache.hibernate.EhCacheProvider

          </prop>

          <prop key="hibernate.cache.use_query_cache">true</prop>

          <prop key="hibernate.cache.use_second_level_cache">

           true

          </prop>

          <prop key="hibernate.show_sql">false</prop>

          <prop key="hibernate.connection.autocommit">false</prop>

          <prop key="hibernate.format_sql">false</prop>

          <prop key="hibernate.connection.release_mode">on_close</prop>

          <prop key="hibernate.generate_statistics">false</prop>

         

          <prop key="hibernate.hbm2ddl.auto">update</prop>

                   <prop key="org.hibernate.envers.audit_table_suffix">_Audit</prop>

                   <prop key="org.hibernate.envers.revision_field_name">REV</prop>

                   <prop key="org.hibernate.envers.revision_type_field_name">REVTYPE</prop>

                   <prop key="org.hibernate.envers.default_schema">SQN_OWN</prop>

                      <prop key="org.hibernate.envers.revision_on_collection_change">false</prop>

             

         </props>

        </property>

        <property name="dataSource">

         <ref bean="dataSource" />

        </property>

                

        <property name="eventListeners">

         <map>

          <entry key="post-insert">

           <bean class="org.hibernate.envers.event.AuditEventListener" />

          </entry>

          <entry key="post-update">

           <bean class="org.hibernate.envers.event.AuditEventListener" />

          </entry>

          <entry key="post-delete">

           <bean class="org.hibernate.envers.event.AuditEventListener" />

          </entry>

          <entry key="pre-collection-update">

           <bean class="org.hibernate.envers.event.AuditEventListener" />

          </entry>

          <entry key="pre-collection-remove">

           <bean class="org.hibernate.envers.event.AuditEventListener" />

          </entry>

          <entry key="post-collection-recreate">

           <bean class="org.hibernate.envers.event.AuditEventListener" />

          </entry>

         </map>

        </property>

      </bean>

       

       

      When I start up the application I am getting the error HibernateException could not init listeners. After debugging further, The error comes from AuditConfiguration class at :

      AudiConfiguration(Configuration C){

       

      Properties properties = cfg.getProperties();

       

      ReflectionManager reflectionManager = ((AnnotationConfiguration) cfg).getReflectionManager(); failing on classCastException cfg is not an instance of  AnnotationConfiguration ..

       

      What could I be doing wrong ?