I am using Hibernate envers for versioning in a small sample app. My configuration file is:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans">
<!-- Note we added the jpa namespace to this configuration.-->
<!-- Use the H2 database for testing -->
<jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:schema.sql"/>
<jdbc:script location="classpath:test-data.sql"/>
</jdbc:embedded-database>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="packagesToScan"
value="com.apress.prospring3.ch10.domain"/>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.H2Dialect
</prop>
<prop key="hibernate.max_fetch_depth">3</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">10</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- Listeners for Hibernate Envers -->
<prop key="hibernate.ejb.event.post-insert">
org.hibernate.ejb.event.EJB3PostInsertEventListener,
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-update">
org.hibernate.ejb.event.EJB3PostUpdateEventListener,
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-delete">
org.hibernate.ejb.event.EJB3PostDeleteEventListener,
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.pre-collection-update">
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.pre-collection-remove">
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-collection-recreate">
org.hibernate.envers.event.AuditEventListener
</prop>
<!-- Properties for Hibernate Envers -->
<prop key="org.hibernate.envers.audit_table_suffix">_H</prop>
<prop key="org.hibernate.envers.revision_field_name">AUDIT_REVISION</prop>
<prop key="org.hibernate.envers.revision_type_field_name">ACTION_TYPE</prop>
<prop key="org.hibernate.envers.audit_strategy">org.hibernate.envers.strategy.ValidityAuditStrategy</prop>
<prop key="org.hibernate.envers.audit_strategy_validity_end_rev_field_name">AUDIT_REVISION_END</prop>
<prop key="org.hibernate.envers.audit_strategy_validity_store_revend_timestamp">true</prop>
<prop key="org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name">AUDIT_REVISION_END_TS</prop>
</props>
</property>
</bean>
<context:annotation-config/>
<context:component-scan base-package="com.apress.prospring3.ch10.service.springjpa"/>
<jpa:repositories base-package="com.apress.prospring3.ch10.repository"
transaction-manager-ref="transactionManager"
entity-manager-factory-ref="emf"/>
<!-- Define the audit listener in the configuration. The <jpa:auditing ..> tag is to enable the Spring Data
JPA auditing feature, while the bean auditorAwareBean is the bean providing the user information -->
<jpa:auditing auditor-aware-ref="auditorAwareBean"/>
<bean id="auditorAwareBean" class="com.apress.prospring3.ch10.springjpa.auditor.AuditorAwareBean"/>
</beans>
When I run my app, I get the error:
Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.envers.event.AuditEventListener
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
... 35 more
When I run with a pre 4.xx version of hibernate I don't get this error. What has changed with respect to the AuditEventListener after 4.1.0?
Thanks
Mike