-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: envers, Spring 2.5.6, Hibernate 3.3.1
PostPosted: Sat Jan 24, 2009 9:13 pm 
Beginner
Beginner

Joined: Thu Feb 21, 2008 3:31 pm
Posts: 34
Hi all,

I am trying to use envers with my project and cannot set the required event listeners.

I am getting an ArrayStoreException:

Code:
Caused by: java.lang.ArrayStoreException: org.jboss.envers.event.VersionsEventListener
   at org.hibernate.cfg.Configuration.setListener(Configuration.java:1694)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:721)
   at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
   ... 90 more


Here is my configuration
Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="packagesToScan">
         <list>
            <value>com.walterjwhite.domain</value>
         </list>
      </property>
      <property name="cacheProvider" ref="ehCacheProvider"/>

      <!--   Support for revisioning   -->
      <property name="eventListeners">
         <map>
            <entry key="post-insert" value-ref="versionsEventListener"/>
            <entry key="post-update" value-ref="versionsEventListener"/>
            <entry key="post-delete" value-ref="versionsEventListener"/>

            <entry key="pre-collection-update" value-ref="versionsEventListener"/>
            <entry key="pre-collection-remove" value-ref="versionsEventListener"/>
            <entry key="post-collection-recreate" value-ref="versionsEventListener"/>
         </map>
      </property>
   </bean>

   <bean id="ehCacheProvider" class="org.hibernate.cache.EhCacheProvider"/>

   <!--   Versioning Event Listener   -->
   <bean id="versionsEventListener" class="org.jboss.envers.event.VersionsEventListener"/>



Is this the proper way to configure this with Spring?


Walter


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 8:02 am 
Newbie

Joined: Tue Mar 17, 2009 7:06 am
Posts: 1
Hi All,

Following is my configuration

hibernate.jar 3.2.0.cr5
hibernate-annotations.jar 3.3.0.GA
hibernate-commons-annotations.jar 3.0.0.GA
hibernate-entitymanager.jar 3.3.2.GA

and i am trying to integrate Envers with hibernate with following configuration in persistence.xml

Code:
<!-- AUDIT USING ENVERS -->
     <property name="hibernate.ejb.event.post-insert" value="org.jboss.envers.event.VersionsEventListener" /> 
      <property name="hibernate.ejb.event.post-update" value="org.jboss.envers.event.VersionsEventListener" /> 
      <property name="hibernate.ejb.event.post-delete" value="org.jboss.envers.event.VersionsEventListener" /> 
      <property name="hibernate.ejb.event.pre-collection-update" value="org.jboss.envers.event.VersionsEventListener" /> 
      <property name="hibernate.ejb.event.pre-collection-remove" value="org.jboss.envers.event.VersionsEventListener" /> 
      <property name="hibernate.ejb.event.post-collection-recreate" value="org.jboss.envers.event.VersionsEventListener" />
      <!-- AUDIT TABLE CONFIGURATIONS --> 
      <property name="org.jboss.envers.versionsTableSuffix" value="_V" />
      <property name="org.jboss.envers.revisionFieldName" value="ver_rev" />
      <property name="org.jboss.envers.revisionOnCollectionChange" value="true" />
      <property name="org.jboss.envers.revisionFieldName" value="ver_rev" />   


Now, if i keep the collection properties, i get

java.lang.ArrayStoreException: org.jboss.envers.event.VersionsEventListener

while commenting collection entries gives me

NoSuchMethodException exception

Please suggest how can i proceed.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: envers, Spring 2.5.6, Hibernate 3.3.1
PostPosted: Fri Feb 19, 2010 7:22 am 
Newbie

Joined: Fri Feb 19, 2010 6:52 am
Posts: 1
Hi everybody!

I have the next hibernate-conf:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

   <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url" value="jdbc:mysql://localhost/terceros" />
      <property name="username" value="root" />
      <property name="password" value="" />
   </bean>

   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      
      <property name="annotatedClasses">
         <list>
            <value>es.tragsatec.ws.admin.vo.Country</value>
            <value>es.tragsatec.ws.admin.vo.Municipality</value>
            <value>es.tragsatec.ws.admin.vo.PhoneType</value>
            <value>es.tragsatec.ws.admin.vo.Province</value>
            <value>es.tragsatec.ws.admin.vo.StreetType</value>
            <value>es.tragsatec.ws.admin.vo.IdentificationCardType</value>
            <value>es.tragsatec.ws.admin.vo.LegalStatus</value>
            <value>es.tragsatec.ws.admin.vo.Bank</value>
         </list>
      </property>
      
      <property name="namingStrategy">
         <ref bean="namingStrategy" />
      </property>
      
      <property name="eventListeners">
         <map>
            <entry key="post-update">
               <bean class="org.hibernate.envers.event.AuditEventListener"></bean>
            </entry>
            <entry key="post-insert">
               <bean class="org.hibernate.envers.event.AuditEventListener"></bean>
            </entry>
                                <entry key="post-delete">
               <bean class="org.hibernate.envers.event.AuditEventListener"></bean>
            </entry>
         </map>
      </property>

      <property name="hibernateProperties">
         <props>
            <!-- MYSQL -->
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.search.default.directory_provider">
               org.hibernate.search.store.FSDirectoryProvider
              </prop>
            <prop key="hibernate.search.default.indexBase">c:\temp\sgt\index\</prop>
         </props>
      </property>

   </bean>
</beans>


I also have these dependencies:

Code:
<dependency>
         <groupId>org.jboss.envers</groupId>
         <artifactId>jboss-envers</artifactId>
         <version>1.2.2.GA</version>
      </dependency>

                <dependency>
         <groupId>javax.annotation</groupId>
         <artifactId>jsr250-api</artifactId>
         <version>1.0</version>
      </dependency>

               <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-core</artifactId>
         <version>2.5.6</version>
      </dependency>

                <dependency>
         <groupId>javax.annotation</groupId>
         <artifactId>jsr250-api</artifactId>
         <version>1.0</version>
      </dependency>

      <dependency>
         <groupId>javax.persistence</groupId>
         <artifactId>persistence-api</artifactId>
         <version>1.0</version>
      </dependency>


With this stuff the envers project works ok. But I have the same problem as puneetswarup (java.lang.ArrayStoreException) if I declare a listener make of my own:

Code:
package es.tragsatec.ait.oviedo.audit;

import org.hibernate.envers.RevisionListener;

import org.springframework.security.Authentication;
import org.springframework.security.context.SecurityContextHolder;

public class AuditRevisionListener implements RevisionListener {

   public void newRevision(Object revisionEntity) {
      AuditRevisionEntity are = (AuditRevisionEntity) revisionEntity;
      Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
      are.setUsername(authentication.getName());
   }

}



And the code of the RevisionEntity:

Code:
@Entity
@RevisionEntity(AuditRevisionListener.class)
public class AuditRevisionEntity {
   
   @Id
    @GeneratedValue
    @RevisionNumber
    private int id;
   
   @RevisionTimestamp
    private long timestamp;
   
   private String username;

   public String getUsername() { return username; }
   public void setUsername(String username) { this.username = username; }
   public int getId() {
      return id;
   }
   public void setId(int id) {
      this.id = id;
   }
   public long getTimestamp() {
      return timestamp;
   }
   public void setTimestamp(long timestamp) {
      this.timestamp = timestamp;
   }

   @Transient
    public Date getDate() {
        return new Date(this.getTimestamp());
    }

.../...



Any idea?

Thanks in advance,

Luis


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.