It's not a secret anymore!*
The moose likes Object Relational Mapping and the fly likes Conflicting persistence unit definitions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Conflicting persistence unit definitions" Watch "Conflicting persistence unit definitions" New topic
Author

Conflicting persistence unit definitions

John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
Spring 3.1.1
Maven 3.0.4
JPA
Eclipse wtp indigo

Hello,
I am getting the following exception on server startup. I have just one persistence.xml in my project. Any ideas? Thanks Eric

Caused by: java.lang.IllegalStateException: Conflicting persistence unit definitions for name 'cassandra_pu': file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/cassandra/WEB-INF/classes/, file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/cassandra/WEB-INF/classes/
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:362)
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:326)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:235)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 62 more

My context file:




My persistence.xml file is in META-INF where it should be:



Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1680
    
    7

If you use this



You should not even have a persistence.xml. Read the java doc for more info.

I would try either removing that line or removing your persistence.xml


[How To Ask Questions][Read before you PM me]
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

Bill

If you remove persistence.xml, where will "cassandra_pu" be defined?
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1680
    
    7

You would set thetJpaPropertyMap and JpaVendorAdapter on the LocalContainerEntityManagerFactory.

I found a blog describing it here:

http://krams915.blogspot.com/2011/10/spring-310rc1-jpa-entitymanagerfactory.html
John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
Thanks for the responses. I'll try it out.

Eric
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Conflicting persistence unit definitions