Rename persistence.xml

I wrote a utility that will be reused by web-apps and relies on JPA. Those web-apps will likely also rely on JPA. This implies 2 persistence.xml files in the classpath... which can lead to conflicts (and according to posts I read - it does!).
So I must rename persistence.xml and somehow tell the EntityManager to read the renamed file. I saw many posts on how to achieve it with Spring, but none on how to do it with vanilla JPA. I'd rather not go the Spring route since its JPA documentation is awful.
Can it be done? If yes, how?
Thanks

I ended up solving the problem by using Spring. Spring has a mechanism that allows naming persistence.xml anything you want.

Similar Messages

  • Problem with Persistence.xml in JDev final after migration

    Hi,
    I am trying to migrate a current project from JDev 11gTp4 to the JDev production release. When deploying the EJB module I get the following problem though (Stack from DefaultServer.log)
    weblogic.application.ModuleException: Exception preparing module: EJBModule(Nexus-NexusModel-ejb)
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:452)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
         at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:197)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:89)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:723)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1190)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:248)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"
         at javax.xml.parsers.DocumentBuilderFactory.setSchema(DocumentBuilderFactory.java:561)
         at weblogic.xml.jaxp.RegistryDocumentBuilder.setupDocumentBuilderFactory(RegistryDocumentBuilder.java:393)
         at weblogic.xml.jaxp.RegistryDocumentBuilder.getDefaultDocumentBuilderFactory(RegistryDocumentBuilder.java:359)
         at weblogic.xml.jaxp.RegistryDocumentBuilder.getDocumentBuilder(RegistryDocumentBuilder.java:298)
         at weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:150)
         at org.eclipse.persistence.platform.xml.jaxp.JAXPParser.parse(JAXPParser.java:163)
         at org.eclipse.persistence.platform.xml.jaxp.JAXPParser.parse(JAXPParser.java:197)
         at org.eclipse.persistence.internal.oxm.record.DOMUnmarshaller.unmarshal(DOMUnmarshaller.java:213)
         at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:309)
         at org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsReader.read(XMLEntityMappingsReader.java:72)
         at org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsReader.read(XMLEntityMappingsReader.java:112)
         at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.loadStandardMappingFiles(MetadataProcessor.java:343)
         at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.loadMappingFiles(MetadataProcessor.java:271)
         at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:294)
         at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:830)
         at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:189)
         at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:330)
         at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:123)
         at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:331)
         at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptor(AbstractPersistenceUnitRegistry.java:245)
         at weblogic.deployment.ModulePersistenceUnitRegistry.<init>(ModulePersistenceUnitRegistry.java:63)
         at weblogic.ejb.container.deployer.EJBModule.setupPersistenceUnitRegistry(EJBModule.java:209)
         at weblogic.ejb.container.deployer.EJBModule$1.execute(EJBModule.java:310)
         at weblogic.deployment.PersistenceUnitRegistryInitializer.setupPersistenceUnitRegistries(PersistenceUnitRegistryInitializer.java:62)
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:376)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
         at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:197)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:89)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:723)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1190)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:248)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    My persistence.xml looks like
    <?xml version="1.0" encoding="windows-1252" ?>
    <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="Nexus-ejbPU">
    <provider>
    org.eclipse.persistence.jpa.PersistenceProvider
    </provider>
    <jta-data-source>
    jdbc/NexusPoolDS
    </jta-data-source>
    <mapping-file>
    META-INF/orm.xml
    </mapping-file>
    <properties>
    <property name="eclipselink.target-server" value="WebLogic_10"/>
    <property name="eclipselink.logging.file" value="Toplink.log"/>
    <property name="eclipselink.logging.timestamp" value="true"/>
    <property name="eclipselink.logging.exceptions" value="true"/>
    <property name="eclipselink.logging.session" value="true"/>
    </properties>
    </persistence-unit>
    </persistence>
    orm.xml looks like this
    <?xml version="1.0" encoding="windows-1252" ?>
    <entity-mappings 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"
    xmlns="http://java.sun.com/xml/ns/persistence/orm">
    <persistence-unit-metadata>
    <persistence-unit-defaults>
    <schema>
    XXX
    </schema>
    </persistence-unit-defaults>
    </persistence-unit-metadata>
    <package>
    za.co.medscheme.model.persistence.xxx
    </package>
    <schema>
    XXX
    </schema>
    </entity-mappings>
    I have noticed that the persistence.xml file have changed quite drastically from the version we had in TP4 release during project upgrade, but can not explain the problem we are getting. I have also tried to just create a dummy project and create a persistence unit, and the file looks exactly the same afterwards. Any thoughts?
    Drikus

    Just thought I would add a temporary solution to the problem for those of you sitting with the same issue.
    In the root folder of your application you will find a src folder with a meta-inf folder and weblogic-application.xml inside.
    Add the following before the closing weblogic-application tag...
    <xml>
    <parser-factory>
    <saxparser-factory>
    weblogic.xml.jaxp.WebLogicSAXParserFactory
    </saxparser-factory>
    <document-builder-factory>
    weblogic.xml.jaxp.WebLogicDocumentBuilderFactory
    </document-builder-factory>
    <transformer-factory>
    weblogic.xml.jaxp.WebLogicSAXTransformerFactory
    </transformer-factory>
    </parser-factory>
    </xml>
    If there wasnt an xml tag in the file, it seems that JDeveloper somehow adds one on the fly for you pointing to an oracle xml parser that does not contain the setSchema method required by weblogic on deployment.
    Hope this helps anybody else that has this problem.
    Regards
    Drikus Britz

  • Override JNDI names in persistence.xml and @resource annotation

    I have a Java EE 7 application that I am developing for use with both GlassFish and WildFly, but I have discovered that both application servers use a slightly different format for specifying JNDI names.
    In GlassFish the persistence.xml file references the data source jdbc/myDataSouce, but in WildFly the data source needs to be java:/jdbc/myDataSource.The same is also true for classes that are annotated with @Resource. In GlassFish the annotation for a class using JavaMail would be @Resource(name = "mail/myMailSession"), but to deploy onto WildFly this would need to be @Resource(name = "java:mail/myMailSession").
    The only solution I've got at present is using Maven to create two different releases of the EAR file, with one EAR file containing a persistence.xml file with the data source jdbc/myDataSouce for use with GlassFish, and the second EAR file containing a persistence.xml file with the data source java:/jdbc/myDataSource for use with WildFly. Unfortunately, I haven't found a solution for the @Resource annotation.
    I've taken a look at the documentation for glassfish-application.xml and glassfish-ejb-jar.xml and have tried using resource-ref to override the JNDI names but the application fails to deploy due to an error in the name.
    My question is does GlassFish provide any capability to override the JNDI names specified in the persistence.xml file and classes with the @resource annotation?
    Many Thanks
    Paul

    Have you been able to solve this? I'm attempting to understand what Web Server 7 can do with regard to Java Persistence and what elements of it require Glassfish.
    I've also spent great amounts of time in WS6.1 trying to figure out why a JNDI resource couldn't be found. The rules of thumb I've learned are:
    - Try dropping the *'java:/comp/env/* prefix; just use jdbc/pact part
    - Make sure all referrences (in web.xml and sun-web.xml) are identical with regard to that name.
    I'm hoping you're not still dealing with this (it's been two months!) but if anybody else stumbles on this, maybe it'll help them.
    Dave

  • Problems with deploy on OC4J 10.1.3.2 with hibernate persistence.xml

    Hi all,
    I can't deploy an EAR/WAR into oc4j 10.3.2.0 stand-alone, I have the following error message :
    2008-03-26 19:50:38.721 NOTIFICATION Binding opsky-webapp-1.0-SNAPSHOT web-module for application opsky to site default-web-site under context root /opsky
    08/03/26 19:50:38 oracle.oc4j.admin.internal.DeployerException: [opsky:opsky-webapp-1.0-SNAPSHOT] - Exception creating EntityManagerFactory using PersistenceProvider class org.hibernate.ejb.HibernatePersistence for persistence unit ApplicationEntityManager.
    08/03/26 19:50:38 at com.evermind.server.ejb.exception.DeploymentException.exceptionCreatingEntityManagerFactory(DeploymentException.java:130)
    08/03/26 19:50:38 at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.createContainerEntityManagerFactory(PersistenceUnitManagerImpl.java:197)
    08/03/26 19:50:38 at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.initializePersistenceUnit(PersistenceUnitManagerImpl.java:159)
    08/03/26 19:50:38 at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.initialize(PersistenceUnitManagerImpl.java:86)
    08/03/26 19:50:38 at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:733)
    08/03/26 19:50:38 at com.evermind.server.ApplicationStateRunning.getHttpApplication(ApplicationStateRunning.java:414)
    08/03/26 19:50:38 at com.evermind.server.Application.getHttpApplication(Application.java:571)
    08/03/26 19:50:38 at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.createHttpApplicationFromReference(HttpSite.java:1990)
    08/03/26 19:50:38 at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.<init>(HttpSite.java:1909)
    08/03/26 19:50:38 at com.evermind.server.http.HttpSite.addHttpApplication(HttpSite.java:1606)
    08/03/26 19:50:38 at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:238)
    08/03/26 19:50:38 at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:99)
    08/03/26 19:50:38 at oracle.oc4j.admin.internal.ApplicationDeployer.bindWebApp(ApplicationDeployer.java:547)
    08/03/26 19:50:38 at oracle.oc4j.admin.internal.ApplicationDeployer.doDeploy(ApplicationDeployer.java:202)
    08/03/26 19:50:38 at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:93)
    08/03/26 19:50:38 at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun(OC4JDeployerRunnable.java:52)
    08/03/26 19:50:38 at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(DeployerRunnable.java:81)
    08/03/26 19:50:38 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)
    08/03/26 19:50:38 at java.lang.Thread.run(Thread.java:619)
    2008-03-26 19:50:38.987 NOTIFICATION Application Deployer for opsky FAILED.
    2008-03-26 19:50:38.987 NOTIFICATION Application UnDeployer for opsky STARTS.
    I'm using hibernate 3 with spring, here is my persistence.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
    <persistence-unit name="ApplicationEntityManager" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>org.appfuse.model.User</class>
    <class>org.appfuse.model.Role</class>
    </persistence-unit>
    </persistence>
    Does enyone know anything about this issue?

    Hi,
    It would be helpful if you copied and pasted the error messages you get.
    For what its worth, it probably isn't a bug, just a configuration problem. You may need to alter more than your application.xml file.
    If you developed the EJBs with JDeveloper, you can create a deployment descriptor that adds the necessary configuration files for the OAS platform, and package them into a WAR or EAR. Use Enterprise Manager to deploy the WAR/EAR to the OAS OC4J and everything will be placed where its needed.
    More info in the JDeveloper and OAS 10.1.3 documentation.
    Jim

  • Multiple PUs in a single persistence.xml

    Hi,
    I'm trying to define two different PUs for a standalone and Java EE environments, so a single persistence.xml could be used.
    Here goes the persistence.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
      <persistence-unit name="derbyPU" transaction-type="RESOURCE_LOCAL">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <class>pl.jaceklaskowski.jsf.tomahawk.entities.Pracownik</class>
        <properties>
          <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver" />
          <property name="openjpa.ConnectionURL" value="jdbc:derby:target/derbyDB;create=true" />
          <property name="openjpa.ConnectionUserName" value="app" />
          <property name="openjpa.ConnectionPassword" value="app" />
          <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
          <property name="openjpa.Log" value="DefaultLevel=WARN,SQL=TRACE" />
        </properties>
      </persistence-unit>
      <persistence-unit name="Kadry">
        <jta-data-source>jdbc/derby</jta-data-source>
        <class>pl.jaceklaskowski.jsf.tomahawk.entities.Pracownik</class>
      </persistence-unit>
    </persistence>and here goes the managed bean of a JSF application I'm developing.
    package pl.jaceklaskowski.jsf.tomahawk;
    import java.util.List;
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    public class Pracownicy {
        @PersistenceContext(name="Kadry")
        EntityManager em;
        DataModel pracownicy = new ListDataModel();
        public DataModel getLista() {
            List resultList = em.createQuery("SELECT p FROM Pracownik p ORDER BY p.lastName").getResultList();;
            pracownicy.setWrappedData(resultList);
            return pracownicy;
    }When I run it on GF v2b36 I'm getting the following exception:
    com.sun.enterprise.deployment.backend.IASDeploymentException: Deployment Error -- Could not resolve a persistence unit corresponding to the persistence-context-ref-name [Kadry] in the scope of the module called [C:\projs\myfaces-tomahawk\target\myfaces-tomahawk]. Please verify your application.
            at com.sun.enterprise.deployment.BundleDescriptor.findReferencedPUsViaPCRefs(BundleDescriptor.java:689)
            at com.sun.enterprise.deployment.WebBundleDescriptor.findReferencedPUs(WebBundleDescriptor.java:709)
            at com.sun.jdo.spi.persistence.support.ejb.ejbc.PersistenceProcessor.getAllPersistenceUnitDescriptors(PersistenceProcessor.java:158)
            at com.sun.jdo.spi.persistence.support.ejb.ejbc.PersistenceProcessor.processApplication(PersistenceProcessor.java:119)
            at com.sun.jdo.spi.persistence.support.ejb.ejbc.DeploymentEventListenerImpl.processApplication(DeploymentEventListenerImpl.java:198)
            at com.sun.jdo.spi.persistence.support.ejb.ejbc.DeploymentEventListenerImpl.processEvent(DeploymentEventListenerImpl.java:159)
            at com.sun.jdo.spi.persistence.support.ejb.ejbc.DeploymentEventListenerImpl.notifyDeploymentEvent(DeploymentEventListenerImpl.java:109)
            at com.sun.enterprise.deployment.backend.DeploymentEventManager.notifyDeploymentEvent(DeploymentEventManager.java:66)
            at com.sun.enterprise.deployment.backend.ModuleDeployer.handlePostDeployEvent(ModuleDeployer.java:618)
            at com.sun.enterprise.deployment.backend.ModuleDeployer.postDeploy(ModuleDeployer.java:607)
            at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:172)
            at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:174)
            at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
            at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:892)
            at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
            at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:761)
            at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
            at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)I double-checked that the jar with the Kadry PU is in WEB-INF/lib directory of the web application.
    Does anyone have any idea what might be wrong?
    Jacek
    Jacek Laskowski
    http://www.jaceklaskowski.pl

    Hi Jacek,
    The attribute you should set is unitName(), not name(). name() defines the location of the
    @PersistenceContext dependency within the component environment (java:comp/env). It
    is independent of the dependency type and appears on all Java EE environment annotations :
    @EJB, @Resource, etc.
    unitName() specifies the name of the associated persistence unit. If there is only one defined it's
    not needed. However, in your case there are two so since it's not specified there isn't enough
    information to resolve the correct one.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to rename the XML file generated during payment run

    Hi,
    We have a requirement to rename the XML file during payment run, format some fields of XML file and upload it onto Application server with the new XML file name. All these activities need to be performed during payment run F110.
    Please let know if there is any User exit or Enahancement to achieve these functionalities.
    Thanks !
    Regards,
    Ravinder

    Hi,
    We have achieved the second functionality also i.e. populating the additional nodes or custom nodes of an extended tree.
    This is what we have done...
    We have copied the standard exit FM: DMEE_EXIT_TEMPLATE_EXTEND_ABA into a custom one and assigned it to each (custom) node in 'Source' tab. Line item text FPAYP-SGTXT will not be returned via this FM, so we fetched it explicitly from BSEG table using the input FPAYP-DOC2R (this field will have the company code, document number, fiscal year and item no, all concatenated).
    Thanks,
    /Ravinder

  • SAPUI5 Project - Missing persistence.xml

    Hi,
    I have created a simple SAPUI5 application having an Employee form. The values should be saved in the HANA DB. As there are multiple ways to save the data in HANA, I am exploring the JPA based approach.
    I am following the Container-Managed Persistence Example and able to create the project. Instead of Dynamic Web project, I have created SAPUI5 project and also changed the project facets as mentioned in the tutorial.
    Now the problem is that I am not able to deploy the project on SAP HCP. It is giving me following error -
    2014 09 04 07:45:24#+00#ERROR#unknown.jul.logger##anonymous#fs-watcher##p137653trial#jadyn#web##Unable to load Persistence Unit from EAR: /usr/sap/ljs/webapps/jadyn, module: file:/usr/sap/ljs/webapps/jadyn/WEB-INF/classes/. Exception: unexpected element (uri:"http://xmlns.jcp.org/xml/ns/persistence", local:"persistence"). Expected elements are <{http://java.sun.com/xml/ns/persistence}persistence>javax.xml.bind.UnmarshalException: unexpected element (uri:"http://xmlns.jcp.org/xml/ns/persistence", local:"persistence"). Expected elements are <{http://java.sun.com/xml/ns/persistence}persistence>
      at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:647)....
    2014 09 04 07:45:27#+00#ERROR#unknown.jul.logger##anonymous#fs-watcher##p137653trial#jadyn#web##FAIL ... EmpBean:
    Missing required persistence.xml for @PersistenceContext ref "em" to unit ""|
    2014 09 04 07:45:27#+00#ERROR#unknown.jul.logger##anonymous#fs-watcher##p137653trial#jadyn#web##Invalid EjbModule(name=jadyn, path=/usr/sap/ljs/webapps/jadyn)|
    2014 09 04 07:45:27#+00#ERROR#unknown.jul.logger##anonymous#fs-watcher##p137653trial#jadyn#web##FAIL ... jadyn:
    Missing required persistence.xml for @PersistenceContext ref "em" to unit ""|
    2014 09 04 07:45:27#+00#ERROR#unknown.jul.logger##anonymous#fs-watcher##p137653trial#jadyn#web##Invalid WebModule(name=jadyn, path=/usr/sap/ljs/webapps/jadyn)|
    2014 09 04 07:45:27#+00#ERROR#org.eclipse.virgo.web.enterprise.openejb.deployer.VirgoDeployerEjb##anonymous#fs-watcher##p137653trial#jadyn#web##Error while deploying application with real path '/usr/sap/ljs/webapps/jadyn' and web context path '/jadyn'org.apache.openejb.config.ValidationFailedException: Module failed validation. AppModule(name=jadyn)
    Anyone has any idea on what wrong I am doing.  Please check the attached error log for more details. Thanks!
    Regards
    Abhi

    Actually yes - please get familiar with The SCN Rules of Engagement! In particular, don't push if you haven't received an answer after 3 hours or so.
    Now, I am not sure how a UI5 project is exported and what it packages but I would recommend using a Dynamic Web project which is intended for Java web development and supports JPA. You can also have your HTML and JS static resources in it.
    Cheers,
    --Vlado

  • Multiple persistence.xml files

    I've got a situation where I have one persistence.xml file with many persistence-unit's. My problem is that during deployment not all of the persistence-units are useable, so I get errors. My question is can I use multiple persistence.xml files in an application if each persistence.xml file defined only one persistence-unit?
    Mark

    While JPA supports multiple persistence units in a single persistence.xml most of the tooling options (Eclipse, JDeveloper) focus on supporting a single persistence unit. Using multiple persistence.xml files on different classpath roots should also work. I recall seeing a bug related to this in the EclipseLink queue. Is this the JPA implementation you are using?
    Doug

  • Deploying persistence.xml in ejb-jar componts

    Hi,
    If you are deploying ejb-jar components which are packaged independently and are remote components but they all access the same database, do you put the persistence.xml in the META-INF of each component (ejb-jar). If not, where would it go?
    I can find lots of references to having a single persistence.xml with many configurations but if (theoretically) each bean is deployed on a separate JVM/Container how would it access the persistence.xml?
    Thanks.

    If you are deploying the EJB JARs to different Java EE servers, then yes, each EJB JAR needs its own persistence.xml. You would configure each Java EE server to point to the same JDBC resource.
    If you are deploying them all to the same server, you should package the entity classes into a single JAR file, and include that JAR file in an EAR with the other EJB JARs. In that scenario, persistence.xml is in the JAR's META-INF directory. The JAR file can either be in the top-level of the EAR, or in the EAR's library directory. In this case, the scope of the persistence unit is the entire EAR.
    -ian

  • Share persistence.xml file between two EJB modules in EAR

    Hello, everybody!
    First of all, I would like to say that I already posted this question in another forum:
    [http://community.jboss.org/thread/154128?tstart=0]
    But as I haven't got any answer from there and this issue is very crucial to me I'm posting it here too in the hope that I get an answer. So, here it goes:
    I have two EJB modules in an EAR module. I would like to know how to share a single persistence.xml file with these two EJB modules. If I replicate the persistence.xml file in the two EJB modules, the EAR project deploys ok, but of course that's not what we want. If I remove the persistence.xml file from any of the EJB projects, the EAR doesn't deploy properly. I'm stuck with this. I've already tried many kind of configurations but none worked. I really would like to have some help with this issue to proceed working. This is my EAR structure:
    solicitacoes-ejb.jar       (EJB session beans)
    solicitacoes-dao.jar       (EJB interfaces)
    solicitacoes-dao-jpa.jar   (EJB session beans)
    solicitacoes-ejbClient.jar (entities and EJB interfaces)
    solicitacoes-web.war
    META-INF/This is my application.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <application
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
    version="5">
        <display-name>solicitacoes-ear</display-name>
        <module>
            <ejb>solicitacoes-ejb.jar</ejb>
        </module>
        <module>
            <ejb>solicitacoes-dao-jpa.jar</ejb>
        </module>
        <module>
            <web>
                <web-uri>solicitacoes-web.war</web-uri>
                <context-root>solicitacoes</context-root>
            </web>
        </module>
    </application>If I remove the persistence.xml file from one of the EJB modules, let's say solicitacoes-dao-jpa.jar, I get this error when deploying the EAR file:
    ... 39 more
    Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'null' in AbstractVFSDeploymentContext@28359170{vfs:///C:/jboss-6.0.0.20100429-M3/server/default/deploy/solicitacoes-ear.ear/solicitacoes-dao-jpa.jar/}
    at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107) [:1.0.2-alpha-1]
    at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:778) [:1.3.1]
    at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1517) [:1.3.1]
    at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130) [:1.3.1]
    ... 43 moreI need help with this issue. As you could see, the EJB container doesn't like to see an EJB module without a persistence.xml file. This is clearly a dumb decision though. I agree with it if there was only one EJB module in an EAR. But the container should have been smart enough to require only one persistence.xml file in an EAR module with more than one EJB module, and share that persistece context with the whole EAR.
    Acting the way it is acting now, the container forces us to duplicate the persistece.xml file and kill our application modularity. This is clearly wrong. I've already tried to put the entity classes and persistence.xml file in the lib directory of the EAR, but it didn't work either. The container needs to have the persistence.xml file in both EJB modules.
    I don't know if this is a JBoss implementation decision or if it comes from the Java EE 6 specification. Whatever it is, it goes against all good modular and good design decision. Please if some of you know how to solve this, took a little time to tell me how. I would be very grateful.
    Thank you in advance.
    Marcos

    Dear Mr. gimbal2,
    In another occasion I would not reply to such a 'helpful' answer like the one you gave me (yes, it is undoubtedly an answer because that's how you classified it in the beginning of your reply), but as today I have plenty of time here in my job, for this week we're not working full time as usual, I decided to reply to it.
    You have to completely overhaul your attitude.I really didn't know I was taking so personal on this issue to have to 'completely overhaul my attitude'. Thank you for pointing that out.
    In stead of calling the technology dumb, admit to yourself that perhaps you don't understand it properly and that your ideas of what is correct design perhaps is a little lacking. I didn't call the technology dumb because I stated very clearly that I don't know for sure if it is working this way. I said in the last paragraph:
    +"I don't know if this is a JBoss implementation decision or if it comes from the Java EE 6 specification. Whatever it is, it goes against all good modular and good design decision."+
    So, I let implicit the fact that the technology or the implementation of the technology is dumb only if it doesn't allow this possibility. Regarding the fact that your said that I should
    admit to myself that perhaps I don't understand it properly, where did I stated in my question that I understand it completely? It's clear in the last paragraph that I don't. If I'm asking that's because I have doubts. Maybe my ideas of what is correct is wrong, and that's why I'm here in this forum. But everyone with a good sense knows that what I propose in this discussion is by no means a wrong design decision. Where is it a sin to have more than one EJB module in a EAR and a persisntece.xml file shared for the whole EAR? Does everyone that has more than one EJB module in an EAR module need to connect to more than one database? Is it wrong to want to have your DAO implementation in a separate EJB module in order to make deployment easy and also changes, if you later want to replace that implementation with another one without affecting
    the other modules? I don't think that a design decision that seeks this is lacking. I don't think that Java EE today is a dumb technoloby, but everyone knows that before it gets to the present level, it was a technology known to have made big dumb decisions that the community latter corrected, with ideas like O/R mapping (Hibernate), dependency injection (Spring), Struts and lots of other examples that we all know. No one can deny this and lots of wrong things will continue to be fixed in later releases.
    Maybe when you rise yourself back to that level, you open yourself up again to thinking in correct solutions in stead of trying to hammer through your own poorly chosen one.To be sincere, I see you took very personal about this issue. You really shows to be someone that has no respect to other people and you judge them too. I must say that I got surprised by the way you answered my post. I didn't expect to get such sarcastic answer to what I asked. I personally don't act this way. If I can't help a person, I also don't try to ridicularize him.
    Marcos

  • Deploy failure due to jta-data-source in persistence.xml

    Hey All,
    This is driving me insane. Every example, including the Sun tutorials (which don't work on my instance of Glassfish), list persistence.xml files like:
    "<?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
         <persistence-unit name="persistence_sample">
    <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
    <jta-data-source>jdbc/SamplesDB</jta-data-source>
    <non-jta-data-source>jdbc/SamplesDB__nontx</non-jta-data-source>
    </persistence-unit>
    </persistence>"
    I've tried every combination of <persistence...> tags, with namespace definitions, posted in examples on the internet, but my problem is, any time I deploy my ear with a "<jta-data-source>" tag specified, I receive the following failure from the App Server:
    "Error loading deployment descriptors for module [pi-0] Line 26 Column 24 -- Deployment descriptor file META-INF/persistence.xml in archive [pi-ejb.jar]. cvc-complex-type.2.4.a: Invalid content was found starting with element 'jta-data-source'. One of '{"http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
         at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:352)
         at com.sun.enterprise.deployment.backend.AppDeployerBase.loadDescriptors(AppDeployerBase.java:327)
         at com.sun.enterprise.deployment.backend.AppDeployer.explodeArchive(AppDeployer.java:332)
         at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:182)
         at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.java:129)
         at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)
         at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
         at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:871)
         at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
         at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:739)
         at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
         at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)
    Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'jta-data-source'. One of '{"http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
         at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:285)
         at com.sun.enterprise.deployment.archivist.Archivist.readPersistenceDeploymentDescriptor(Archivist.java:1718)
         at com.sun.enterprise.deployment.archivist.EjbArchivist.readPersistenceDeploymentDescriptors(EjbArchivist.java:239)
         at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:301)
         at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:200)
         at com.sun.enterprise.deployment.archivist.ApplicationArchivist.readModulesDescriptors(ApplicationArchivist.java:308)
         at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:316)
         ... 11 more"
    Note that this only happens when I have a <jta-data-source> element in the persistence.xml file. When I comment out the jta-data-source, it deploys without problems (though it doesn't do much). Here's my persistence-unit code:
    <persistence-unit name="prodcontext" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>OneOfMyClasses</class>
    <jta-data-source>jdbc/SamplesDB</jta-data-source>
    </persistence-unit>
    Please help.
    Thank you,
    Todd

    Okay okay, my mistake (staring at this thing too long).
    The solution is, I confess I overlooked it, the jta-data-source node in the xml has to follow the exact order specified in the xsd. I was putting it below the class nodes, which is a no-no.

  • How dos the application will know the path of persistence.xml file

    Hi ,
    I am seeing examples for ConatierManaged EntityManager
    @PersistenceContext
    public class Test extends HttpServlet
    public void doGet()
    EntityManager em
    // JnDI Lookup code
    em = (EntityManager) ctx.lookup("java:comp/env/persistence/em");
    em.persist(Employee)
    }Inside web.xml file
    <web-app>
    <persistence-context-ref>
    <persistence-context-ref-name>persistence/em</persistence-context-ref-name>
      <persistence-unit-name>my-pu</persistence-unit-name>
    </persistence-context-ref>
    </web-app>Please tell me how the Application will know the path of persistence.xml file .
    Thank you for reading

    it is predefined; JPA always looks for the persistence.xml file in the META-INF folder.

  • Question about persistence.xml

    Hi,
    I have two persistence units in one persistence.xml file. When I deploy my ejb3 file, my Car entity bean (@Entity) creates two tables in the database (one for each persistence-unit). I want the table created in only one persistence-unit. How I tell to the entity bean what persistence-unit it has to use and what it has not?
    Thanks
    Luiz Carlos

    Ok,
    I find a way.
    All I have to do was put the property
    <property name="hibernate.archive.autodetection" value="false"/>
    in the persistence.xml and define the classes I wanna to use with
    <class>SomeClass</class>
    <class>AnotherClass</class>
    It was too much work but was the only way I found..
    Thanks anyway
    Luiz Carlos

  • Loader persistence.xml

    How does the JVM loader META-INF/persistence.xml?
    any help greatly appreciated!

    Originally posted by: beat.stradax.net
    > 1) When I don't specify any properties:
    > Persistence.createEntityManagerFactory("unitname");
    >
    > The OSGiPersistenceInitializationHelper#getClassLoader is called with
    > "bundleresource://7/unitname" and doesn't find an entry for this,
    > because the map contains only a key "unitname".
    >
    > 2) When I specify Thread.currentThread().getContextClassLoader() as a
    > class loader property, this class loader doesn't find the resource
    > "META-INF/persistence.xml" in
    > PersistenceProvider#createEntityManagerFactory:95.
    Well ok. With a class loader property
    "this.getClass().getClassLoader()" it works.
    Beat

  • Exclamation sign in Structure window of persistence.xml

    I always have yellow exclamation sign at the beginning of every item of persistence.xml in Structure window. Is that an error and if it is what kind of error?

    You can roll your mouse over or click the warning to disclose a tool tip that describes the issue.
    --RiC                                                                                                                                                                                                                       

Maybe you are looking for

  • How do I get rid of keychain popups? I never set a keychain password.

    Keychain popups happen CONSTANTLY since I got back from the Apple store when a manufacturer error required a hard drive replacement. I can't sign in to iMessage - although my password works to log me in to the computer, I get a keychain message immed

  • Missing Primary Indexes

    Hi, I have observed that Primary Indexes are missing for Master data Infoobject 'P' table. any advise ? Ellora

  • Ways of role assigment

    Hello, What are the dirrent ways of role assigment in R/3 1) direct role assigment (Role based authorazation concept) 2)Indirect role assigment(Structural Authorazation based i.e. HR security,based on position) is there any onther method? Thansk, Pra

  • Ical time zone problem

    I travel between the east and west coast frequently, carrying my iphone and ibook. I schedule appointments at the time they will be wherever it is I am, without thinking about where I am when I am scheduling them. I want my ical on both devices to ke

  • IPad 2 will not charge shows nothing in screen

    Havnt used my ipad for about 3 weeks and have come to charge, when I initially plugged it in to charge I just got the screen with the apple Logo and the sign showing connect to power.  When I did nothing happened and now there is nothing on my screen