Deploy Fails with: Exception Creating ENTITYMANAGER using Persistence Provider

(Doc ID 785959.1)

Last updated on APRIL 18, 2013

Applies to:

Oracle TopLink - Version 10.1.3.4 and later
Information in this document applies to any platform.
***Checked for relevance on 18-Apr-2013***

Symptoms

Deploying an application where the deployed archive and/or the java classpath contains multiple occurrences of the deployment mapping file can raise the following exception:

Operation failed with error: [<application name>:<context root>] -
Exception creating EntityManagerFactory using PersistenceProvider class
oracle.toplink.essentials.PersistenceProvider for persistence unit <persistence-unit name>.
Exception [TOPLINK-7252] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))):
oracle.toplink.essentials.exceptions.ValidationException
Exception Description: There are multiple mapping files called[orm.xml] in classpath for
persistence unit named [ <persistence-unit name>].
at oracle.toplink.essentials.exceptions.ValidationException.nonUniqueMappingFileName(ValidationException.java:1155)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.readExplicitlySpecifiedMappingFiles(MetadataProcessor.java:406)
at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.readMappingFiles(MetadataProcessor.java:357)
at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:359)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:607)
at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:244)
at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.createContainerEntityManagerFactory(PersistenceUnitManagerImpl.java:192)

Changes

Typically in a Java CLASSPATH the same class or resource can exist multiple times, and by default the one first on the classpath is used by the class loader.  This sometimes makes developing/testing easier because a set of classes/resources can be put ahead on the classpath to override classes. When moving into production however, this becomes an issue because the orm.xml file cannot have multiple copies during application deployment.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms