Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Multiple Mapping-Files in PersistenceUnit(I try to apply multiple mapping files in one persistence unit, but: Exception Description: Predeployment of PersistenceUnit [fnp-db] failed. )
icon5.gif  Multiple Mapping-Files in PersistenceUnit [message #648625] Thu, 13 January 2011 17:29 Go to next message
Gerald  is currently offline Gerald
Messages: 4
Registered: January 2011
Junior Member
Hi,
i try to combine some entity managers because establishing of 4 connections to the database takes too long at program startup, also the handling is too complicated.

Question: is it generally possible to have multiple <mapping-file> tags in a persistence unit?

if yes: what do i do wrong?
at first the stack trace:

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


now the persistence.xml:
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
  <persistence-unit name="fnp-db">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <mapping-file>com/adva/yp/api/data_accessor/database/orm/orm_fast_access.xml</mapping-file>
        <mapping-file>com/adva/fnp/pypdb/db_classes/orm_planner.xml</mapping-file>
      <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
            <property name="eclipselink.target-database" value="MySQL"/>
            <property name="eclipselink.jdbc.batch-writing" value="JDBC" />
            <property name="eclipselink.persistence-context.flush-mode" value="COMMIT" />
            <property name="eclipselink.jdbc.read-connections.shared" value="true"/>
            <property name="eclipselink.jdbc.connections.initial" value="1"/>
            <property name="eclipselink.jdbc.connections.min" value="1"/>
            <property name="eclipselink.jdbc.connections.max" value="128"/>
            <property name="eclipselink.cache.size.default" value="5000"/>
            <!--<property name="eclipselink.ddl-generation" value="create-tables"/>-->

            <property name="eclipselink.logging.level" value="SEVERE"/>
            <property name="eclipselink.logging.thread" value="true"/>
            <property name="eclipselink.logging.session" value="true"/>
            <property name="eclipselink.logging.exceptions" value="true"/>
            <property name="eclipselink.logging.timestamp" value="true"/>
        </properties>

  </persistence-unit>
</persistence>


The mapping files:
orm_fast_access.xml
<?xml version="1.0" encoding="Cp1252" ?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
                 version="1.0">

  <persistence-unit-metadata>
    <xml-mapping-metadata-complete/>
  </persistence-unit-metadata>
  <mapped-superclass class="com.adva.yp.api.model.core.YPDatabaseItem" metadata-complete="true">
    <attributes>
      <id name="id">
        <generated-value strategy="IDENTITY"/>
      </id>
      <version name="dbVer"/>
      <transient name="logger"/>
    </attributes>
  </mapped-superclass>

  <!-- YPInstanceItem <-> YP_INSTANCE -->
  <entity class="com.adva.yp.api.model.core.YPInstanceItem">
    <table name="yp_instance">
      <unique-constraint> <column-name>YP_INSTANCE_UNIQUE_ID</column-name> </unique-constraint>
    </table>
    <inheritance strategy="TABLE_PER_CLASS"/>
    <!-- Primary Key -->
    <attribute-override name="id"> <column name="YP_INSTANCE_ID"/> </attribute-override>
    <attributes>
      <!-- Basic mappings -->
      <basic name="uniqueId"> <column name="YP_INSTANCE_UNIQUE_ID"/> </basic>
      <basic name="name"> <column name="YP_INSTANCE_NAME"/> </basic>
      <basic name="instanceKey"> <column name="YP_INSTANCE_KEY"/> </basic>
      <basic name="categoryTypeId"> <column name="YP_CATEGORY_TYPE_ID"/> </basic>
      <basic name="instanceTypeId"> <column name="YP_INSTANCE_TYPE_ID"/> </basic>
      <basic name="description"> <column name="YP_INSTANCE_DESCRIPTION" column-definition="VARCHAR(1000)"/> </basic>
      <basic name="oemDescription"> <column name="YP_INSTANCE_OEMDESCRIPTION" column-definition="VARCHAR(1000)"/> </basic>
      <basic name="resolved"> <column name="YP_INSTANCE_RESOLVED"/> </basic>
      <basic name="hidden"> <column name="YP_INSTANCE_HIDDEN"/> </basic>

      <!-- Hierarchy Mapping to parent and child instance items -->
      <many-to-one name="instanceParent" target-entity="com.adva.yp.api.model.core.YPInstanceItem" fetch="LAZY">
        <join-column name="YP_INSTANCE_ID_PARENT"/>
        <cascade> <cascade-persist/> <cascade-merge/> <cascade-refresh/> </cascade>
      </many-to-one>

      <!-- All Entities -->
      <one-to-many name="entities" target-entity="com.adva.yp.api.model.core.YPEntityClass"
                   mapped-by="referencedInstanceItem" fetch="LAZY">
        <map-key name="name"/>
        <cascade> <cascade-all/> </cascade>
      </one-to-many>
      <!--
            <one-to-many name="childInstanceItems" target-entity="com.adva.yp.api.model.YPInstanceItem" fetch="LAZY" mapped-by="instanceParent">
              <cascade>  <cascade-remove/>  </cascade>
            </one-to-many>
      -->
      <!--<transient name="logger" />-->
    </attributes>
  </entity>

  <!-- YPEntityClass <-> YP_ENTITY -->
  <entity class="com.adva.yp.api.model.core.YPEntityClass" metadata-complete="true">
    <table name="yp_entity_fast">
      <unique-constraint>
        <column-name>YP_ENTITY_TYPE_ID</column-name>
        <column-name>YP_INSTANCE_ID</column-name>
      </unique-constraint>
    </table>
    <inheritance strategy="TABLE_PER_CLASS"/>
    <!-- Primary Key -->
    <attribute-override name="id"> <column name="YP_ENTITY_ID"/> </attribute-override>
    <attributes>
      <!-- Basic mappings -->
      <basic name="name"> <column name="YP_ENTITY_NAME"/> </basic>
      <basic name="entityClassTypeId"> <column name="YP_ENTITY_TYPE_ID"/> </basic>

      <!-- referenced YPInstanceItem -->
      <many-to-one name="referencedInstanceItem" target-entity="com.adva.yp.api.model.core.YPInstanceItem"
                   optional="false">
        <join-column name="YP_INSTANCE_ID" nullable="false"/>
        <cascade> <cascade-persist/> <cascade-merge/> <cascade-refresh/> </cascade>
      </many-to-one>

      <!-- All Parameters -->
      <many-to-many name="params" target-entity="com.adva.yp.api.model.core.YPParameter" fetch="LAZY">
        <join-table name="yp_entity_parameter_fast">
          <join-column name="YP_ENTITY_ID"/>
          <inverse-join-column name="YP_PARAMETER_ID"/>
          <unique-constraint>
            <column-name>YP_ENTITY_ID</column-name>
            <column-name>YP_PARAMETER_ID</column-name>
          </unique-constraint>
          <!-- -->
        </join-table>
        <cascade> <cascade-persist/> <cascade-merge/> <cascade-refresh/> </cascade>
      </many-to-many>

      <transient name="paramsMap"/>
      <!--<transient name="logger" />-->
    </attributes>
  </entity>

  <!-- YPParameter <-> YP_PARAMETER -->
  <entity class="com.adva.yp.api.model.core.YPParameter">
    <table name="yp_parameter"> <!-- schema="yp"> -->
      <unique-constraint>
        <column-name>YP_PARAMETER_TYPE_ID</column-name>
        <column-name>YP_PARAMETER_VALUE_STRING</column-name>
      </unique-constraint>
    </table>
    <inheritance strategy="TABLE_PER_CLASS"/>
    <!-- Primary Key -->
    <attribute-override name="id"> <column name="YP_PARAMETER_ID"/> </attribute-override>
    <attributes>
      <basic name="parameterTypeId"> <column name="YP_PARAMETER_TYPE_ID"/> </basic>
      <basic name="parameterName"> <column name="YP_PARAMETER_NAME"/> </basic>
      <basic name="doubleValue"> <column name="YP_PARAMETER_VALUE_DOUBLE"/> </basic>
      <basic name="longValue"> <column name="YP_PARAMETER_VALUE_LONG"/> </basic>
      <basic name="stringValue"> <column name="YP_PARAMETER_VALUE_STRING"/> </basic>
      <basic name="rangeMin"> <column name="YP_PARAMETER_VALUE_RMIN"/> </basic>
      <basic name="rangeMax"> <column name="YP_PARAMETER_VALUE_RMAX"/> </basic>

      <!--<transient name="logger" />  -->
    </attributes>
  </entity>

  <entity class="com.adva.yp.api.data_accessor.cache.YPCacheObject">
    <table name="yp_cache"/>
    <inheritance strategy="TABLE_PER_CLASS"/>
    <attribute-override name="id"> <column name="YP_CACHE_PK"/> </attribute-override>
    <attributes>
      <basic name="headKey"> <column name="YP_CACHE_HEAD"/> </basic>
      <basic name="positiveKey"> <column name="YP_CACHE_POS"/> </basic>
      <basic name="negativeKey"> <column name="YP_CACHE_NEG"/> </basic>
      <basic name="hitCount"> <column name="YP_CACHE_HITCOUNT"/> </basic>
      <basic name="instanceItemUniqueId"> <column name="YP_INSTANCE_UNIQUE_ID"/> </basic>

      <one-to-one name="instanceItemId" target-entity="com.adva.yp.api.model.core.YPInstanceItem" fetch="LAZY">
        <join-column name="YP_INSTANCE_ID"/>
        <cascade> <cascade-refresh/> </cascade>
      </one-to-one>
    </attributes>
  </entity>

  <entity class="com.adva.yp.api.data_accessor.database.util.YPParameterRankingTupel">
    <table name="yp_parameter_ranking"/>
    <attributes>
      <id name="id"> <column name="PRIM_KEY"/> <generated-value strategy="IDENTITY"/> </id>
      <basic name="type"> <column name="YP_PARAMETER_NAME"/> </basic>
      <basic name="rankingValue"> <column name="YP_PARAMETER_AVG_HIT"/> </basic>
    </attributes>
  </entity>
</entity-mappings>


orm_planner.xml
(i thought it wouldn't work because the classes are inherited from the same superclass as in fast_access, so i commented it out, but still it won't work)
<?xml version="1.0" encoding="Cp1252" ?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
                 version="1.0">

  <persistence-unit-metadata>
    <xml-mapping-metadata-complete/>
  </persistence-unit-metadata>

  <!--<mapped-superclass class="com.adva.yp.api.model.core.YPDatabaseItem" metadata-complete="true">
    <attributes>
      <id name="id"> <generated-value strategy="IDENTITY"/> </id>
      <version name="dbVer"/>
      <transient name="logger"/>
    </attributes>
  </mapped-superclass>-->

  <entity class="com.adva.fnp.pypdb.db_classes.PropertyDBImpl">
    <table name="fnp_property">
      <unique-constraint>
        <column-name>FNP_PROPERTY_INSTANCE</column-name>
        <column-name>FNP_PROPERTY_KEY</column-name>
        <column-name>FNP_PROPERTY_VALUE</column-name>
      </unique-constraint>
    </table>
    <!--<inheritance strategy="TABLE_PER_CLASS"/>-->
    <!-- Primary Key -->
    <!--<attribute-override name="id"> <column name="FNP_PROPERTY_ID"/> </attribute-override>-->
    <attributes>
       <id name="id"><column name="FNP_PROPERTY_ID"/></id>
      <!-- Basic mappings -->
      <basic name="instance"> <column name="FNP_PROPERTY_INSTANCE"/> </basic>
      <basic name="key"> <column name="FNP_PROPERTY_KEY"/> </basic>
      <basic name="value"> <column name="FNP_PROPERTY_VALUE"/> </basic>
    </attributes>
  </entity>

  <entity class="com.adva.fnp.pypdb.db_classes.CurrencyDBImpl">
    <table name="fnp_currency">
      <unique-constraint>
        <column-name>FNP_CURRENCY_TYPE</column-name>
      </unique-constraint>
    </table>
    <!--<inheritance strategy="TABLE_PER_CLASS"/>-->
    <!-- Primary Key -->
    <!--<attribute-override name="id"> <column name="FNP_CURRENCY_ID"/> </attribute-override>-->
    <attributes>
      <!-- Basic mappings -->
      <id name="id"> <column name="FNP_CURRENCY_ID"/> </id>
      <basic name="currencyType"> <column name="FNP_CURRENCY_TYPE"/> </basic>
      <basic name="ratio"> <column name="FNP_CURRENCY_RATIO"/> </basic>
    </attributes>
  </entity>
</entity-mappings>


if i add each mapping file to one persistence unit, everything is fine.

does somebody have an idea how to solve that? its not a good option to write everything in 1 file because 1 file comes out of an company internal api.

Thanks for help in advance

Gerald

Re: Multiple Mapping-Files in PersistenceUnit [message #649074 is a reply to message #648625] Mon, 17 January 2011 14:33 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Seems to be a bug, please log the bug and vote for it.

My guess is the null-pointer occurs because, m_persistenceUnitDefaults is null. Adding a <persistence-unit-defaults> tag to each mapping file may fix the issue.


James : Wiki : Book : Blog : Twitter
Re: Multiple Mapping-Files in PersistenceUnit [message #651497 is a reply to message #648625] Mon, 31 January 2011 12:54 Go to previous messageGo to next message
Gerald  is currently offline Gerald
Messages: 4
Registered: January 2011
Junior Member
Thanks, now it works fine.
how do i log a bug and vote for it?
Re: Multiple Mapping-Files in PersistenceUnit [message #651538 is a reply to message #651497] Mon, 31 January 2011 15:27 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

See,

http://wiki.eclipse.org/EclipseLink/Bugs


James : Wiki : Book : Blog : Twitter
Previous Topic:struggling to call a stored procedure with OBJECT parameter...
Next Topic:can't create a new object
Goto Forum:
  


Current Time: Tue Oct 21 17:03:29 GMT 2014

Powered by FUDForum. Page generated in 0.05602 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software