Code:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authDBentityManagerFactory' defined in class path resource [auth-db-jpa.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: AuthDB] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) ~[spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) ~[spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) [grizzly-framework.jar:1.9.46]
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) [grizzly-utils.jar:1.9.46]
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) [grizzly-utils.jar:1.9.46]
at java.lang.Thread.run(Thread.java:679) [na:1.6.0_24]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: AuthDB] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) ~[hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) ~[hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) ~[hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268) ~[spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310) ~[spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) ~[spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ~[spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
... 54 common frames omitted
Caused by: org.hibernate.event.service.spi.EventListenerRegistrationException: Duplicate event listener found
at org.hibernate.event.service.internal.EventListenerGroupImpl.listenerShouldGetAdded(EventListenerGroupImpl.java:143) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.event.service.internal.EventListenerGroupImpl.appendListener(EventListenerGroupImpl.java:108) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.ejb.event.JpaIntegrator.integrate(JpaIntegrator.java:137) ~[hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:301) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744) ~[hibernate-core-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94) ~[hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) ~[hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
... 60 common frames omitted
I use two org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean and each has its own jpaProperties one is for Authentication and the second for rest of Application.
I tried to use : 15.8. Conditional auditing : http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch15.html with org.hibernate.ejb.event.JpaIntegrator
Because errors come from Class : EventListenerGroupImpl row 143
http://grepcode.com/file/repo1.maven.org/maven2/org.hibernate/hibernate-core/4.1.3.Final/org/hibernate/event/service/internal/EventListenerGroupImpl.java#EventListenerGroupImpl.listenerShouldGetAdded%28java.lang.Object%29
org.hibernate.ejb.event.JpaIntegrator has a different DuplicationStrategy
but I have the error again and again