Results 1 to 3 of 3

Thread: Spring 3 and Hibernate Enverrs 4

  1. #1
    Join Date
    Aug 2012
    Posts
    5

    Post Spring 3 and Hibernate Enverrs 4

    Hi Everybody:

    I have trying to set up spring 3 and Hibernate Envers 4, but I couldnīt, please I need some recommendations about how to set up this version, If you have some settings about which version I should use and setting the pom.xml and the aplicacionConext.xml, I would be happy.

    These is my currently
    POM.xml
    <!-- Hibernate -->
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.1.4.Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-annotations</artifactId>
    <version>3.5.6-Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.3.0.Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate.common</groupId>
    <artifactId>hibernate-commons-annotations</artifactId>
    <version>4.0.1.Final</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-envers</artifactId>
    <version>4.1.4.Final</version>
    </dependency>

    applicationContext.xml

    <bean id="com.axcessfinancial.tools.audit.entityManagerF actory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="jpaProperties">
    <props>

    <!-- Listeners for Hibernate Envers -->
    <prop key="hibernate.ejb.event.post-insert">
    org.hibernate.ejb.event.EJB3PostInsertEventListene r,
    org.hibernate.envers.event.AuditEventListener
    </prop>
    <prop key="hibernate.ejb.event.post-update">
    org.hibernate.ejb.event.EJB3PostUpdateEventListene r,
    org.hibernate.envers.event.AuditEventListener
    </prop>
    <prop key="hibernate.ejb.event.post-delete">
    org.hibernate.ejb.event.EJB3PostDeleteEventListene r,
    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>

    <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.ValidityAuditStrateg y
    </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>

    But when I am trying to run my test, It show me this message:


    java.lang.IllegalStateException: Failed to load ApplicationContext
    ... 59 more
    Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.envers.event.AuditEventListener
    at org.hibernate.service.classloading.internal.ClassL oaderServiceImpl$1.findClass(ClassLoaderServiceImp l.java:99)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.hibernate.service.classloading.internal.ClassL oaderServiceImpl.classForName(ClassLoaderServiceIm pl.java:138)
    ... 60 more

    I have sought on the Maven Dependency into hibernate-envers-4.X.X but I canīt find the class org.hibernate.envers.event.AuditEventListener, please what is the class that I need? I could be EnversListener, How to setting this new class on the applicationContext.

    Thanks in advance.
    Fred

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Please use [ code][/code ] tags when posting code/xml/stacktrace so that we can easily read them, currently it isn't really readable..

    I suggest a read of the hibernate reference guide how to configure envers, you are using the wrong way (as you probably already noticed by the stacktrace). For hibernate4 you don't need to configure all the post-* and pre-* listeners those are automatically registered if Envers is detected, so in short remove those.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Aug 2012
    Posts
    5

    Default

    Hi Marten,

    Thanks for help me, could you give me what are the links where I can found this information or examples.

    Thanks.
    Fred

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •