I am trying a small sample project which configures HibernateEventListeners. My xml file is:
I am Configuring the EntityManagerFactory for Entity Versioning. When I run the test program I get the following errors:HTML 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>
.......
2012-12-28 16:21:43,356 INFO [org.hibernate.cfg.Environment] - <Hibernate 3.6.8.Final>
2012-12-28 16:21:43,356 INFO [org.hibernate.cfg.Environment] - <hibernate.properties not found>
2012-12-28 16:21:43,356 INFO [org.hibernate.cfg.Environment] - <Bytecode provider name : javassist>
2012-12-28 16:21:43,356 INFO [org.hibernate.cfg.Environment] - <using JDK 1.4 java.sql.Timestamp handling>
2012-12-28 16:21:43,387 INFO [org.hibernate.ejb.Version] - <Hibernate EntityManager 3.6.8.Final>
2012-12-28 16:21:43,403 INFO [org.hibernate.ejb.Ejb3Configuration] - <Processing PersistenceUnitInfo [
name: default
...]>
2012-12-28 16:21:43,450 INFO [org.hibernate.cfg.Configuration] - <Mapping package com.apress.prospring3.ch10.springjpa>
2012-12-28 16:21:43,544 INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - <Destroying singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@ffdadcd: defining beans [dataSource,transactionManager,org.springframework. aop.config.internalAutoProxyCreator,org.springfram ework.transaction.annotation.AnnotationTransaction AttributeSource#0,org.springframework.transaction. interceptor.TransactionInterceptor#0,org.springfra mework.transaction.config.internalTransactionAdvis or,emf,org.springframework.context.annotation.inte rnalConfigurationAnnotationProcessor,org.springfra mework.context.annotation.internalAutowiredAnnotat ionProcessor,org.springframework.context.annotatio n.internalRequiredAnnotationProcessor,org.springfr amework.context.annotation.internalCommonAnnotatio nProcessor,org.springframework.context.annotation. internalPersistenceAnnotationProcessor,contactAudi tService,springJpaContactService,contactAuditRepos itory,contactRepository,org.springframework.data.r epository.core.support.RepositoryInterfaceAwareBea nPostProcessor#0,org.springframework.dao.annotatio n.PersistenceExceptionTranslationPostProcessor#0,o rg.springframework.orm.jpa.support.PersistenceAnno tationBeanPostProcessor#0,org.springframework.cont ext.config.internalBeanConfigurerAspect,org.spring framework.data.jpa.domain.support.AuditingEntityLi stener,org.springframework.data.jpa.domain.support .AuditingBeanFactoryPostProcessor,auditorAwareBean ,org.springframework.context.annotation.Configurat ionClassPostProcessor$ImportAwareBeanPostProcessor #0]; root of factory hierarchy>
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExc eptionTranslationPostProcessor#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'emf' defined in class path resource [spring-data-app-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Unable to instantiate specified event (post-update) listener class:
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 94)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:225)
at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:291 )
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplic ationContext.registerBeanPostProcessors(AbstractAp plicationContext.java:728)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:449)
at com.apress.propring3.ch10.SpringJpaAuditSample.mai n(SpringJpaAuditSample.java:18)
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'emf' defined in class path resource [spring-data-app-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Unable to instantiate specified event (post-update) listener class:
Things seem to die at creating the second event listener, the "post-update". The first one is created fine and in fact if I move the "post-update" to the last position, it still dies on that one.
Thanks in Advance
Mike


Reply With Quote
V
