Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336047 - Multiple Mapping files do not work in one persistence unit
Summary: Multiple Mapping files do not work in one persistence unit
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-02 05:23 EST by Gerald CLA
Modified: 2022-06-09 10:22 EDT (History)
5 users (show)

See Also:


Attachments
Proposed changes (4.96 KB, patch)
2011-05-09 14:53 EDT, Guy Pelletier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gerald CLA 2011-02-02 05:23:24 EST
I placed 2 or more xml-mapping files to 1 persistence unit.
following exception occured:

Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.adva.fnp.pypdb.YP_DBHdlr.init(YP_DBHdlr.java:209)
	at com.adva.fnp.pypdb.YP_DBHdlr.getInstance(YP_DBHdlr.java:130)
	at com.adva.fnp.planner.common.yp.YPComponentFactory.getInstance(YPComponentFactory.java:145)
	at com.adva.fnp.planner.common.yp.YPControllerImpl.<init>(YPControllerImpl.java:68)
	at com.adva.fnp.planner.common.yp.YPControllerProvider.getNonConfigurationYPController(YPControllerProvider.java:124)
	at com.adva.fnp.planner.common.yp.YPControllerProvider.getServiceFor(YPControllerProvider.java:109)
	at com.adva.fnp.planner.common.yp.YPControllerProvider.getServiceFastFor(YPControllerProvider.java:76)
	at com.adva.fnp.planner.common.yp.components.WavelengthHelper.getWavelengthType(WavelengthHelper.java:160)
	at com.adva.fnp.planner.PlannerTestCase.<clinit>(PlannerTestCase.java:99)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:169)
	at com.intellij.junit4.JUnit4TestRunnerUtil.loadTestClass(JUnit4TestRunnerUtil.java:170)
	at com.intellij.junit4.JUnit4TestRunnerUtil.appendTestClass(JUnit4TestRunnerUtil.java:154)
	at com.intellij.junit4.JUnit4TestRunnerUtil.buildRequest(JUnit4TestRunnerUtil.java:74)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:61)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:192)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@11b86e7
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [fnp-db] failed.
Internal Exception: java.lang.NullPointerException
	at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)
	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:136)
	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:65)
	at com.adva.fnp.common.persistence.FNP_DBHelper.initEntityManagerFactory(FNP_DBHelper.java:192)
	at com.adva.fnp.common.persistence.FNP_DBHelper.<clinit>(FNP_DBHelper.java:58)
	... 22 more
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [fnp-db] failed.
Internal Exception: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1005)
	at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:88)
	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:127)
	... 25 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [fnp-db] failed.
Internal Exception: java.lang.NullPointerException
	at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210)
	... 28 more
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.metadata.xml.XMLPersistenceUnitMetadata.merge(XMLPersistenceUnitMetadata.java:156)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.setPersistenceUnitMetadata(MetadataProject.java:1663)
	at org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings.processPersistenceUnitMetadata(XMLEntityMappings.java:602)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processEntityMappings(MetadataProcessor.java:454)
	at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:437)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:959)
	... 27 more

The workaround was to add a <persistence-unit-defaults> tag to each mapping file.

The full details are in this thread:
http://www.eclipse.org/forums/index.php?t=msg&goto=651497&S=752ceb16cec25c31813cafb8d3723f4b#msg_651497
Comment 1 Guy Pelletier CLA 2011-02-03 10:42:39 EST
You can also get around the issue by removing one of the persistence unit metadata from one of the mapping files as they are the same (you would have seen a conflict exception otherwise had they been different). Typically a persistence unit metadata is only specified in one mapping file but it is valid to have it in multiples, e.g. if you want to seperate Eclipselink specific metadata from JPA metadata into an eclipselink-orm.xml. (an eclipselink-orm.xml also has the power to override as well and avoid conflict exceptions as mentioned previously)
Comment 2 Tom Ware CLA 2011-02-10 09:10:43 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 3 Guy Pelletier CLA 2011-05-09 14:53:50 EDT
Created attachment 195126 [details]
Proposed changes
Comment 4 Guy Pelletier CLA 2011-05-09 15:24:15 EDT
Changes have been submitted.

Verified by: Tom Ware

Test: Metadata processing error therefore existing XML model modified to expose the exception. With the fix in place, the exception goes away and all tests pass (full regression test suite and extended jpa test suite).
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:22:12 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink