Persistence Units: Transaction Type

Hi,
I'm just getting into Java EE 5 and EJB3. I've found many examples of persistence.xml files with the persistence-units' transaction-types set to either JTA or LOCAL_RESOURCE. What I haven't been able to find is any discussion on when one type should be used over the other.
I've been playing a little in NetBeans 5.5 and created a persistence.xml for an entity class library. The design view of the xml file doesn't have any options to switch from one to the other (that I can see anyway). Mine is set to use RESOURCE_LOCAL. I know I could manually edit the file to use JTA, but should I? Why would I? Why does NB only allow for RESOURCE_LOCAL? I don't know how relevant it is, but the provider is toplink essentials.
If anyone can point me to a good resource that discusses these issues, I would be grateful.
Thanks in advance,
Shelli

You apparently have configured it as a container managed entity manager. It roughly means that the container is injecting the entity manager in the environment and controlling the transactions itself, rather than that you are controlling the transactions yourself in the code.
Either change it to JTA to get the container to do the work, or if you want to keep it RESOURCE_LOCAL somehow, then stop using container managed injection and control the transactions yourself.
This has not much to do with JDBC however. In the future better use the [EJB forum|http://forums.sun.com/forum.jspa?forumID=13].

Similar Messages

  • Operating Unit List Of Values is Null When Entering Transaction Types

    Hi,
    Operating Unit List Of Values is null when entering Transaction Types in Receivables Manager responsibility. I also re-checked MO: Security Profile and MO:Operating Unit Profile options that were set correctly. Please let me know how to troubleshoot the problem and fix accordingly.
    Thanks for the help.
    Regards,
    Sri

    There are some pointers in the below note
    Troubleshooting Transaction Types In Oracle Receivables [ID 1090878.1]
    Mahendra

  • Multiple Persistence Units AND one transaction

    Hello,
    I'm using JPA implementation for my EJB Project.
    I have 2 persistence units and I'm using them in the same method.
    I want to persist 2 object belonging each one to a different persistence unit
    The 2 persistence units are related to different databases.
    Everything is going fine and no exception is raised BUT only one object is persisted and the other one is not.
    Have anyone had a similar problem before.
    Any help will be appreciated.
    Thanks in advance.
    Edited by: ImaneA on Jan 18, 2011 9:29 AM

    @Yordan :
    First of all, thanks a lot for you answer.
    At the end, I didn't use two EJB Projects :
    1 - I used only one datasource( associated to one database ) in the persistence.xml
    2 - I created a DBLink in SQL Server
    3 - I created a synonym in the first database to get data from the second database.
    And it works
    But thanks for the answer, I may use you solution in my next project
    @Rolf :
    No, In NWA I've declared my datasources as normal datasources.
    But Plz if you have docs that talks about XDataSources plz share them and thanks in advance.
    Edited by: ImaneA on Jan 25, 2011 9:21 AM

  • Weblogic 10.3.0 not picking up persistence unit

    Hello,
    I am facing a problem where Weblogic does not seem to pickup the persistence unit:
    [wldeploy] Target state: deploy failed on Server examplesServer
    [wldeploy] java.lang.IllegalArgumentException: No persistence unit named 'dao' is available in scope ejb-app. Available persistence units: []OS: Windows XP (Development Environemnt)
    WebLogic Server Version: 10.3.0.0
    Though I'm working via Eclipse Helios, I am using Weblogic generated (and later modified) Ant scripts to compile, build and deploy to my local Weblogic install, in a 'split development' setup.
    Following is the file strutcture:
    source
    +---build.xml (Ant script)
    +---APP-INF
    |    +---lib
    |         +--- * (shared libraries)
    |
    +---META-INF
    |    +---application.xml
    |    +---weblogic-application.xml
    |
    +---web-app
    |    +---WEB-INF
    |         +---src
    |         +---lib
    |
    +---ejb-app
         +---com.example.ejb.data (Contains Entity annotations)
          |    +---Pojo1.java
          |    +---Pojo2.java
          |
          +---com.example.ejb.ctrl (Contains business logic and services)
          |    +---MyService.java
          |
          +---META-INF
               +---ejb-jar.xml
                +---weblogic-ejb-jar.xml
                +---persistence.xml     Here is my persistence.xml:
    <?xml version="1.0"?>
    <persistence 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"
         version="1.0">
         <persistence-unit name="dao" transaction-type="RESOURCE_LOCAL">
              <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
              <jta-data-source>OraDS</jta-data-source>
              <non-jta-data-source>OraDS</non-jta-data-source>
              <class>com.example.ejb.data.Pojo1</class>
              <class>com.example.ejb.data.Pojo2</class>
              <properties>
                   <property name="eclipselink.target-server" value="WebLogic_10" />
                   <property name="eclipselink.logging.level" value="FINEST" />
              </properties>
         </persistence-unit>
    </persistence>            I am attempting to inject the persistence unit via annotation in MyService.java (a @Stateless session bean):
    @PersistenceContext(unitName = "dao")
    private EntityManager entityManager;     I had done the same with 10.3.0's default Kodo provider and was getting the same issue.
    I've moved the persistence.xml to source/APP-INF, source/APP-INF/lib, source/META-INF and run deploys, it still gives me the error.
    The whole EAR is built with wlcompile and appc as per Split Directory development flow.
    For some reason, Weblogic does not seem to pick up the "dao" persistence unit into its JNDI tree, application wide or 'ejb-app' module scoped.
    Any direction on what next should I be looking at would be helpful.
    Edited by: Vyoma on May 25, 2011 10:15 PM
    Fixed code formatting.

    Pierluigi Vernetto, thanks for that link. Though it was for a web module consumption of the persistence package, I was able to adapt it for use by my ejb module.
    Here is my solution, under split-directory development workflow.
    Create the persistence module, place the persistence.xml in that module's META-INF.
    Create an Ant task in the build.xml to 'wlcompile' and JAR it to the EAR direcotries APP-INF/lib directory.
    Exclude the persistence module from the rest of the 'wlcompile' and 'appc' tasks.
    I was then able to inject it with annotation in my EJB module.
    dvohra16, thanks for that pointer. Now that I've been able to solve, the pressure is off (and shifted to other things). But I will surely check your option out. If I can get that working, it will be much easier than tinkering around with the build.xml and would be the normal flow of split-directory development workflow.
    As of now, I will say this thread as 'solved', but if I get it working the way you mention (on my sandbox project), I will surely come back and update this thread.
    Edited by: Vyoma on May 27, 2011 11:21 AM

  • Toplink transaction-type problem

    we have web application ear file, inside ear file persistence.xml is looking like
    <persistence-unit name="TCA" transaction-type="JTA">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <jta-data-source>jdbc/TcaConnDS</jta-data-source>
    We have deployed same ear file to 4 different oc4j instances and 2 oc4j instances application working without problem. Another 2 oc4j instances application does not work and we have to modify transaction-type="JTA" to transaction-type="RESOURCE_LOCAL" to make it work.
    Since we have deployed same ear to all oc4j instances, 2 oc4j only work with transaction-type="JTA" and the other 2 only work with transaction-type="RESOURCE_LOCAL".
    I think it is OC4J configuration to affect toplink behavior. Which oc4j configuration can affect toplink transaction-type setting?
    Thanks for the help.

    Very odd. What does not work, what error do you get?
    Are the OC4J servers that same version, what is different about them?
    James : http://www.eclipselink.org

  • Toplink JPA properties in persistence unit are ignored

    I'm trying to make some EJB3 stateless session bean webservices, using the toplink essentials (build b41 beta 2) shipped with OC4J stand-alone 10.1.3.3.0.
    Basically I have a 'model' project with my EJB3 entity beans, and a persistence.xml. Then I have a webservice project, that has the model project as a dependency. Both projects are in the same application in JDeveloper. I use a deployment profile to deploy to my seperate OC4J stand-alone instance.
    My service runs and deploys fine. The persistence unit is read, and the correct datasource is selected and logged in on. However I notice two things:
    - the container complains during deployment, telling me property toplink.server.platform.class.name is deprecated and I should use toplink.target-server. However, I've set the property toplink.target-server as a property in my persistence.xml file...
    - I don't see any Toplink logging, although I've set the property toplink.logging.level to FINE in the persistence.xml.
    This leads me to believe that the properties are somehow ignored. Has anyone experienced this as well? Any hints/tips/suggestions on how to fix this?
    Cheers,
    Bas
    My persistence.xml:
    <?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="VervoerPublicatiesPU" transaction-type="JTA">
        <provider>oracle.toplink.essentials.PersistenceProvider</provider>
        <jta-data-source>jdbc/SQLPUBDS</jta-data-source>
        <class>a.b.c.A</class>      
        <class>a.b.c.B</class>
        <properties>
            <property name="toplink.logging.level" value="FINE"/>
            <property name="oracle.toplink.essentials.config.CacheType" value="SoftWeak"/>
            <property name="toplink.target-database" value="SQLServer"/>
            <property name="toplink.target-server" value="OC4J_10_1_3"/>
        </properties>
      </persistence-unit>
    </persistence>

    I debugged this problem a few weeks ago. There are 2 things going on:
    1. The EJB3 container is automatically adding the property 'toplink.server.platform.class.name' into what is passed to TopLink to ensure the proper container is configured. I have had a bug filed to get this changed to toplink.target-server in the 10.1.3.4 patch-set.
    2. The logging by default goes into the OC4J log found in <HOME>\j2ee\home\log\oc4j
    You can re-configure OC4J to also log these messages to stdout or if you only want them to stdout you can simply set the logging-type in the persistence unit properties.
          <property name="toplink.logging.logger" value="DefaultLogger"/>Doug

  • Classpath problem when deploying a persistence unit (in JBoss)

    Hello,
    I have a JAR file containing an EJB with a persistence.xml file.
    I also have another JAR project containing a persistent annotated POJO class that the persistence unit is supposed to map.
    I defined the class in the persistence unit using a class XML element, but because it's in another JAR, the persistence unit implementation cannot find it. I tried to use a jar-file element instead and specify the name of the JAR containing the POJO, and from the log it seems the class is found and identified as persistent, but then the actual mapping operation fails because of the same reason! I also tried to edit the classpath property in the EJB JAR's manifest fileto include the POJO JAR, but that did not help too...
    Does anyone know what I'm missing here and how to make the persistence unit succeed in mapping the POJO class?
    Thanks.

    Ok, some more details regarding the problem:
    Here is the persistence unit definition:
    <persistence-unit name="NorthwindPU" transaction-type="JTA">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <jta-data-source>jdbc/NorthwindDB</jta-data-source>
              <!-- <class>personal.test.domain_layer.Product</class> -->
              <jar-file>TestProjectPersistence.jar</jar-file>
              <properties>
                   <property name="hibernate.transaction.factory_class"
                        value="org.hibernate.transaction.CMTTransactionFactory"/>
                   <property name="hibernate.transaction.manager_lookup_class"
                        value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                   <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
                   <property name="hibernate.current_session_context_class" value="jta"/>
              </properties>
    </persistence-unit>Here is the stack trace I get when starting the server and deploying the application:
    javax.persistence.PersistenceException: [PersistenceUnit: NorthwindPU] class or package not found
         at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1093)
         at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:871)
         at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:758)
         at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425)
         at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131)
         at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
         at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
         at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
         at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
         at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
         at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
         at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
         at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
         at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
         at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
         at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
         at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
         at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
         at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
         at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
         at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)
         at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
         at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
         at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
         at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
         at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
         at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
         at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
         at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
         at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
         at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
         at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
         at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
         at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
         at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
         at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
         at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
         at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
         at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
         at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
         at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
         at org.jboss.Main.boot(Main.java:209)
         at org.jboss.Main$1.run(Main.java:547)
         at java.lang.Thread.run(Unknown Source)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Getting a datasource from a persistence-unit

    Is there any way to get the name of the datasource (non-jta or jta) from a persistence unit via the EntityManagerFactory or EntityManager instances?
    We need to do some JDBC work (for exotic data types) and are currently parsing the persistence.xml file ourselves to get the data source name (which is an awful thing to do) but would much rather be able to say Connection conn = Utility.getConnection(EntityManger em) or even String datasource = Utility.getDataSource(EntityManager em).
    Thanks, Mark

    Mark,
    Hi, I tried non-JTA code on OC4J.
    Try the following change acc.getDatasourceConnection() - tested on OC4J 10.1.3.4 using a RESOURCE_LOCAL non-JTA connection to Oracle 10g entityManager on a servlet.
    I get the same oracle.jdbc.driver.T4CConnection@18d702e connection to my Oracle 10 db from either the .getConnection() or .getDatasouceConnection() call - verify your persistence.xml properties
    <property name="eclipselink.target-server" value="OC4J"/>
    <property name="eclipselink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="eclipselink.jdbc.platform" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/>
         if (acc != null) {
         //conn = acc.getConnection(); // returns null (I get the same T4CConnection)
         conn = (Connection)acc.getDatasourceConnection(); // returns oracle.jdbc.driver.T4CConnection
    [EL Finer]: 2008.09.30 17:03:07.905--ServerSession(24691161)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--client acquired
    [EL Finer]: 2008.09.30 17:03:13.061--UnitOfWork(18699935)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--acquire unit of work: 11546616
    08/09/30 17:03:20 __Connection: oracle.jdbc.driver.T4CConnection@18d702e
    I suspect you are running a RESOURCE_LOCAL entitymanager on your servlet client (not on an EJB) that defines all database properties like 3) below.
    like
    public class FrontController extends HttpServlet implements Servlet {
         public EntityManagerFactory emf = Persistence.createEntityManagerFactory("unified");
         public EntityManager entityManager = emf.createEntityManager();
    not
    @Local @Stateless
    public class ApplicationService implements ApplicationServiceLocal {
         @PersistenceContext(unitName="unified",type=PersistenceContextType.TRANSACTION)     
         private EntityManager entityManager;
    1) JTA on OC4J - NOPE
    Debugging in to UnitOfWorkImpl - I see the oracle.oc4j.sql.ManagedDataSource@202088
    However, I think this is still a tx datasource because usesExternalTransactionController = true
    uow     UnitOfWorkImpl (id=534)     
         project     Project (id=573)     
              datasourceLogin     DatabaseLogin (id=582)     
                   connector     JNDIConnector (id=592)     
                        dataSource     ManagedDataSource (id=599)     
                             m_connectionManger     OracleConnectionManager (id=613)     
                             m_connectionRetryInterval     1     
                             m_dataSourceName     "OracleDS" (id=619)     
                             m_debug     ManagedDataSourceDebugInfo (id=620)     
                             m_dmsConnectionStatMap     WeakHashMap<K,V> (id=622)     
                             m_loginTimeout     0     
                             m_logWriter     null     
                             m_managedConnectionFactory     ManagedConnectionFactoryImpl (id=624)     
                             m_manageLocalTransactions     true     
                             m_manageSqlObjects     "basic" (id=626)     
                             m_maxConnectAttempts     3     
                             m_mBean     ManagedJDBCDataSource (id=632)     
                             m_password     null     
                             m_reference     null     
                             m_unStattedConnections     WeakHashMap<K,V> (id=698)     
                             m_unStattedConnectionsLock     Object[0] (id=658)     
                             m_url     null     
                             m_user     null     
                   usesExternalTransactionController     true     
    Using your getConnection(EntityManager em) code:
    acc     DatabaseAccessor (id=537)     
         datasourceConnection     null     
    using:
    <persistence-unit name="unified" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <non-jta-data-source>jdbc/OracleDS</non-jta-data-source>
    <properties>
    <property name="eclipselink.target-server" value="OC4J"/>
    2) non-JTA on OC4J - NOPE
    using..
    entityManager.getTransaction().begin(); // non-JTA
    System.out.println("__Connection: " + getConnection(entityManager));
    on..
    <persistence-unit name="unified" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <non-jta-data-source>jdbc/OracleDS</non-jta-data-source>
    does not work with...
         @PersistenceContext(unitName="unified",type=PersistenceContextType.TRANSACTION)     
         private EntityManager entityManager;
    08/09/30 16:45:59 Exception: Cannot use resource level transactions with a container managed EntityManager
    3) non-JTA, non container managed on OC4J - YES
    using..
         // Local non-JTA application managed EMF and EM
         public EntityManagerFactory emf = Persistence.createEntityManagerFactory("unified");
         public EntityManager entityManager = emf.createEntityManager();
    persistence.xml
    <persistence-unit name="unified" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <properties>
    <property name="eclipselink.target-server" value="OC4J"/>
    <property name="eclipselink.logging.level" value="FINEST"/>
    <property name="eclipselink.session-name" value="eclipselinkwls"/>
    <property name="eclipselink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="eclipselink.jdbc.platform" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/>
    <property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@x.x.x.x:1521:orcl"/>
    <property name="eclipselink.jdbc.user" value="scott"/>
    <property name="eclipselink.jdbc.password" value="password...."/>
    uow     UnitOfWorkImpl (id=518)     
         platform     Oracle10Platform (id=544)     
         project     Project (id=527)     
              aliasDescriptors     null     
              datasourceLogin     DatabaseLogin (id=533)     
                   cacheTransactionIsolation     5     
                   connectionHealthValidatedOnError     true     
                   connector     DefaultConnector (id=542)     
                        connectDirectly     true     
                        databaseURL     "jdbc:oracle:thin:@10.156.53.19:1521:orcl" (id=555)     
                        driver     OracleDriver (id=556)     
                        driverClass     Class<T> (oracle.jdbc.driver.OracleDriver) (id=557)     
                        driverClassName     "oracle.jdbc.driver.OracleDriver" (id=558)     
                        driverURLHeader     "" (id=560)     
    oracle.jdbc.driver.T4CConnection@18d702e
    acc     DatabaseAccessor (id=571)     
         activeBatchWritingMechanism     ParameterizedSQLBatchWritingMechanism (id=575)     
         datasourceConnection     T4CConnection (id=579)     
              database     "x.x.x.x:1521:orcl" (id=638)     
              databaseMetaData     OracleDatabaseMetaData (id=639)     
              databaseProductVersion     "Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production\nWith the Partitioning, OLAP and Data Mining options" (id=641)     
              thinVsessionProgram     "JDBC Thin Client" (id=736)     
              thinVsessionTerminal     "unknown" (id=737)     
              timeout     null     
              timestamptzInGmt     true     
              txnLevel     2     
              txnMode     0     
              url     "jdbc:oracle:thin:@x.x.x.x:1521:orcl" (id=738)     
              useFetchSizeWithLongColumn     false     
              userName     "SCOTT" (id=739)     
              usingXA     false     
              ver     T4C7Oversion (id=740)     
              versionNumber     10201     
              walletLocation     null     
              whichDMS     2     
              wrapper     null     
              xaWantsError     false     
    With the following change...
         public Connection getConnection(EntityManager em) {
         Connection conn = null;
         if (em != null && em.isOpen()) {
         JpaEntityManager jem = (JpaEntityManager)em.getDelegate();
         if (jem != null) {
         Session session = jem.getActiveSession();
         if (session != null) {
         UnitOfWorkImpl uow = (UnitOfWorkImpl)session.acquireUnitOfWork();
         if (uow != null) {
         Accessor acc = uow.getAccessor();
         if (acc != null) {
         //conn = acc.getConnection(); // returns null (I get the same T4CConnection)
         conn = (Connection)acc.getDatasourceConnection(); // returns oracle.jdbc.driver.T4CConnection
         return conn;
    we get...
    [EL Finer]: 2008.09.30 17:03:07.905--ServerSession(24691161)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--client acquired
    [EL Finer]: 2008.09.30 17:03:13.061--UnitOfWork(18699935)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--acquire unit of work: 11546616
    08/09/30 17:03:20 __Connection: oracle.jdbc.driver.T4CConnection@18d702e
    thank you
    [email protected]

  • Multiple persistence units not supported by OEPE 12.1.1.0.1

    Dear Friends -
    Environment
    Oracle Enterprise Pack for Eclipse 12.1.1.0.1
    JPA version : 2.0
    Platform : Eclipse link 2.3.x
    OWLS Version : 12c (12.1.1)
    JDK : jrockit1.6
    Sybase database.
    While developing JPA projects, we are getting error and warning while using Multiple persistence units in persistence.xml.
    Steps :
    1. Create 2 persistence unit in persistence.xml.
    -- Warning saying that "Multiple persistence units defined - only the first persistence unit will be recognized"
    2. Create 2 database connection in OEPE.
    3. Create JPA Entities from Table using first database connection.
    -- No issues.
    4. Create another JPA Entities from Table using second database connection.
    -- Issue is entities created in step3.(is first JPA Entity classes)
    -- Errors from first JPA Entity classes.
    ----1. Table "table_name1" cannot be resolved.
    ----2. Table "table_name1" for column "column_name1" is not valid for this entity.
    5. Second JPA Entity classes are fine.
    Thanks
    Justin.
    Sample persistence.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.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_2_0.xsd">
         <persistence-unit name="PU1" transaction-type="JTA">
              <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
              <jta-data-source>DS1</jta-data-source>
              <class>com.test.FirstEntity</class>     
         </persistence-unit>
         <persistence-unit name="PU2" transaction-type="JTA">
              <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
              <jta-data-source>DS2</jta-data-source>
              <class>com.test.SecondEntity</class>
         </persistence-unit>
    </persistence>

    Also, the reason you are seeing those errors in your first project after generating entities from the second connection is because the project wide schema is being updated to the second connections generation schema. If you go into the JPA project properties you can change it back. This workflow would need to change with multiple persistence unit support.
    Neil

  • Duplicate Persistence Unit error msg?

    Deploying my ear on Weblogic 10 has given me a strange error. It is saying that I am deploying two Persistence Units with the same name, even though I only have one Persistence Uni. As you can see from the stack trace, it's complaining about the same jar for the "First PU and Second PU", even though this jar only has one persistence.xml file. How is this possible?
    <5-Sep-2008 3:56:36 o'clock PM EDT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1220644591734' for task '26'. Error is: 'weblogic.management.DeploymentException: '
    weblogic.management.DeploymentException:
         at weblogic.application.internal.flow.JpaFlow.prepare(JpaFlow.java:47)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:147)
         Truncated. see log file for complete stacktrace
    weblogic.deployment.EnvironmentException: duplicate persistence units with name default in scope appsdirservices-ear-1.111-SNAPSHOT_ear. First PU location: file:C:/oats/bea/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/_appsdir_services-ear-1.111-SNAPSHOT_ear/230cqk/APP-INF/lib/model-jar-1.111-SNAPSHOT.jar. Second PU location: file:C:/oats/bea/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/_appsdir_services-ear-1.111-SNAPSHOT_ear/230cqk/APP-INF/lib/model-jar-1.111-SNAPSHOT.jar
    Here is my persistence.xml:
    <?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="default" transaction-type="RESOURCE_LOCAL">
              <provider>
    org.apache.openjpa.persistence.PersistenceProviderImpl
    </provider>
              <class>com.base.address.Contact</class>
              <class>com.common.address.USAddress</class>          
              <properties>
                   <property name="openjpa.jdbc.DBDictionary" value="oracle(DriverVendor=oracle)"/>
                   <property name="openjpa.Log" value="DefaultLevel=WARN,SQL=TRACE"/>
                   <property name="openjpa.ConnectionURL" value=" jdbc:oracle:thin:@XX.XX.XXX.54:1542:XXXR33"/>
                   <property name="openjpa.ConnectionDriverName" value="oracle.jdbc.driver.OracleDriver"/>
                   <property name="openjpa.ConnectionUserName" value="XXX_XX "/>
                   <property name="openjpa.ConnectionPassword" value="XX_XXX "/>
    </properties>
    </persistence-unit>
    </persistence>

    You should try into a more appropriate forum : [WebLogic Server - General|http://forums.oracle.com/forums/forum.jspa?forumID=570]
    Nicolas.

  • "Could not resolve a persistence unit" error...

    Hello,
    I created a Netbeans Visual Web application. I added an Entity Class from a database table. A resource is added into Server Resources part. when I look at its properties, I see that it's JNDI name is set to "bitkiwiki" and I check the Sun Application Server's JDBC Resources and I see "bitkiwiki" in JDBC Resources.
    My controller class has a EntityManagerFactory element:
        @PersistenceUnit(unitName = "bitkiwiki")
        private EntityManagerFactory emf;When I compile the project it compiles successfully but when I deploy it, I get an error like this:
    Deploying application in domain failed; Deployment Error -- Could not resolve a persistence unit corresponding to the persistence-unit-ref-name .......
    The Persistance UnitName exists in the server resources but it still complains about it.
    What's the problem you think?
    Thanks.

    In the persistence.xml you have something like this:
    <persistence-unit name="EJBCustomerPU" transaction-type="JTA">
    <jta-data-source>cust</jta-data-source>
    <properties>
    </properties>
    </persistence-unit>
    The unitName in the annotation should equal "EJBCustomerPU". I think the "bitkiwiki" is wrong. The "cust" in the above persistence.xml should be the resource you mention in the jdbc section of the app server admin.

  • Multiple persistence units and OneToMany associations

    Hi,
    I have an EAR with two persistence units and corresponding entities. Each is contained within a separate library jar file. Some of the entities in one of the jars refer to entities in the other jar. If I refer to just a single entity (i.e., a OneToOne association), everything builds and deploys with no problems, but if I use a collection (OneToMany association), I get errors when trying to deploy the project.
    I've been playing around with this for a while and have seen different errors such as the following:
    [exec] CLI171 Command deploy failed : Deploying application in domain failed; Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    [exec] Exception Description: predeploy for PersistenceUnit [GrammarUserData] failed.
    [exec] Internal Exception: Exception [TOPLINK-7155] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.ValidationException
    [exec] Exception Description: The type [interface java.util.List] for the attribute [sentencePatterns] on the entity class [class com.leadingstep.grammar.configuration.CommonElementConfiguration] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface.
    I also had the collection defined as a Set and it complained about that as well. I have many other OneToMany associations used between entities within the same persistence unit that use the List interface with no problems, and so that's why I'm wondering if the problem actually comes from the fact that the entities in the failed case belong to different persistence units?
    At another point, the error message I was getting was:
    [#|2009-12-22T20:05:02.427-0500|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|_ThreadID=15;_ThreadName=Thread-32;_RequestID=67ca0eee-64d9-41dc-8093-eec811cb32b6;|Exception occured in J2EEC Phase
    com.sun.enterprise.deployment.backend.IASDeploymentException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [GrammarUserData] failed.
    Internal Exception: Exception [TOPLINK-7250] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: [class com.leadingstep.grammar.configuration.CommonConstructorConfiguration] uses a non-entity [class com.leadingstep.grammar.db.sentences.SentenceGroup] as target entity in the relationship attribute [private java.util.List com.leadingstep.grammar.configuration.CommonConstructorConfiguration.sentenceGroups].
    The target entity it refers to here definitely has the @Entity annotation and again, is associated with other entities within the same persistence unit with no problems.
    Am I right in thinking the problem comes from the association of entities between the different persistence units? Is there something special I have to do to make this work?
    BTW, both persistence units use the <exclude-unlisted-classes> and specifically list every entity that should be included.
    Thanks for any help!
    Renee

    One other thought on this. I'm using Glassfish with Toplink and have it create the tables using:
                   <property name="toplink.ddl-generation" value="create-tables" />
    Could it be something related to the table creation in this case that's causing the problem?
    Renee

  • Purchase Order with Transaction Type: Missing on scrren

    Hi Guys,
    I've been searching for the place in config and master data that determines where the Transaction type is linked the the org. unit or user, but have not been succesfull.
    The selection for transaction type is emty in the "Create Purchase order" screen.
    I have activated ECPO in "Define Transaction Types" in IMG.
    I have had the same problem before but forgot where it was.
    Can any of you mighty people out there point me in the right direction?
    Thanks in advance,
    Thomas
    Message was edited by:
            Thomas Midtbøll

    Hi Thomas,
    The transaction types ECPO & ECDP are maintained in the attributes (BSA) of the org. structure at the Co. Code level or which ever level (P.Org, P.Group) based on the requirements. The user assigned at any of these levels inherit these attributes.
    Also you define number ranges (external & Internal) both for the transaction types in the SPRO > IMG along with the point you mentioned for the activation of Transaction types.
    Hope this answers your query. Clarifications are welcome.
    Rgds,
    Teja

  • Error: "Transaction type could not be determined" during PO Creation fromSC

    Hi all,
    I'm working on SRM 5.5 with ECS.
    During the creation of  a PO  I want to add a SC as an item of PO.
    But when I chose the SC and click on the button Add to PO I recive the error:
    Transaction type could not be determined
    In the organizational unit I set the attribute BSA and DP_PROCT_TY.
    there are other steps I have to do to join the transaction type of SC and PO?
    rgs
    enzo

    Hi Enzo,
    First check if the attribute BSA and DP_PROC_TY have the same value.
    Then in the attribute value for BSA, change the source system for the document type to your SRM system.
    Create a new PO and a shopping cart.
    Try changing the PO by adding the shopping cart
    Hopefully your problem may get resolved.
    Thanks
    Sanjeev

  • Application-Managed EntityManager transaction type must be RESOURCE_LOCAL

    [P-312 of Ejb3 In Action Book"] states:
    "For application-based EntityManager, the transaction-type must be set to RESOURCE_LOCAL in the persistence.xml file".
    but in case the application is running inside container (App server) , it can join JTA transaction. Sp why always transaction-type should be
    RESOURCE_LOCAL.?

    Because the section you took that from is 'Application-managed EntityManagers outside the Java EE Container'. So it would have to be RESOURCE_LOCAL as you are not running in the container (i.e. Java SE/Tomcat).
    If it is running inside a container then you could use JTA as the transaction type.
    m

Maybe you are looking for

  • Satellite Pro P200-HD: How to use it with Win XP

    I recently got the new Satellite Pro P200 HD from Getech. I asked Getech to change the OS to XP because my university will not support Vista. I was told that some of the functionality will be lost with XP, such as the hot key utility and I accepted t

  • My mac keeps freezing and showing the color wheel how can that be fixed

    my mac is soooo slow.  It is very frustrating.  Has been noticeable worse since downloading Lion.  Any suggestions

  • BPEL invokation error from ADF

    Hi All, JDev Version: 11.1.1.3.0 Currently in my application through ADF apps i am invoking BPEL service upon cliking of 'Submit' Button, so that BPEL service will be invoked and it procees. Now getting error as mentioned below. Any input please?? <A

  • Help with Battery Life Droid Razr M KitKat update jacked up my phone like everyone elses'...

    So as with everyone else KitKat has screwed my phone up and I am very annoyed...  Disregarding the fact that I had to download a different keyboard because they removed Swype and screwed up the dialer and the colors of our texts, erased the calendar

  • Capture-db-schema with my-sql

    hello everybody , i create a jdbc resorce and connection pool with Server admin Console and ping everything is ok, but when i get a schema the console bring me this capture-db-schema: [java] using dburl:jdbc:mysql://localhost:3306/comut [java] using