JTA and XA, Mqueue

Trying to get XA to work with Oracle and
Ibm mqueue series.
I'm not having much luck. Lot's of problems
and lack of info?
We want Mqueue to be the TM and oracle to
be the resource? There seems to be no docs
on how to make oracle a XA resource and
understand global transactions?
Any help would be great.
thanks
mark =.=

Trying to get XA to work with Oracle and
Ibm mqueue series.
I'm not having much luck. Lot's of problems
and lack of info?
We want Mqueue to be the TM and oracle to
be the resource? There seems to be no docs
on how to make oracle a XA resource and
understand global transactions?
Any help would be great.
thanks
mark =.=

Similar Messages

  • JTA and JTS

    1. What is the difference between JTA and JTS?
    2. When should we use JTA and when should we use JTS?
    3. In which scenarios that JTA and JTS could not help so that RDBMS specific commands are MUST to LOCK TABLES/ROWS?

    The JTS specifies what happens. The JTA is the API used to talk to a JTS compliant service.

  • Creating a separate transaction in both JTA and nonJTA environment

    I want to record some performance information for each call to my application and I want to write it to the database even if the transaction rolls back. The code needs to run both in a Websphere JTA context and a non-JTA context. The code I wrote works in non-JTA, but doesn't work in Websphere JTA context. How do I create an independent transaction when running in JTA context ? Would starting a new thread work, assuming that started a new JTA transaction ? Is there any other way that would have less overhead ?

    One way would be to use non-JTA data source. I am not sure that WebSphere allows that in JTA case, but you still may be able to create it and put into jndi "by hand".
    Alternatively you may try to use suspend / resume apis defined in jta spec.:
    Transaction tobj = TransactionManager.suspend();
    TransactionManager.resume(tobj);
    For more please see
    Java Transaction API (JTA)
    3.2.3 Suspending and Resuming a Transaction

  • Non jta and autocommit

    i am using mysql, tomcat and toplink. how to set autocommit off?

    my persistence.xml is this
    <?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="SeleccionsCatPU" transaction-type="RESOURCE_LOCAL">
    <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
    <non-jta-data-source>java:comp/env/jdbc/selcat</non-jta-data-source>
    <class>com.xlives.selcat.prueba.Prueba</class>
    <properties>
    <property name="toplink.session.customizer" value="com.xlives.system.jpa.DataSourceSessionCustomizer"/>
    <property name="toplink.logging.level" value="FINEST"/>
    </properties>
    </persistence-unit>
    </persistence>
    and my customizer is this
    JNDIConnector conn = (JNDIConnector)session.getLogin().getConnector();
    conn.setLookupType(JNDIConnector.STRING_LOOKUP);
    session.getLogin().setTransactionIsolation(DatabaseLogin.TRANSACTION_READ_COMMITTED);
    my code is
    EntityTransaction et = em.getTransaction();
    Prueba p = new Prueba();
    em.persist(p);
    p = new Prueba();
    em.persist(p);
    Query q = em.createQuery("SELECT p FROM Prueba p");
    List<Prueba> results = q.getResultList();
    System.out.println(new Date());
    for (Prueba a: results) {
    // System.out.println(a.getFecha());
    Date b = a.getFecha();
    et.rollback();
    after rollback the transaction the table PRUEBA has 2 more rows.

  • Jta and java snippets

    I notice the java spippets run in the same transactional context. Does anyone know if it is possible to use this fact to commit database changes at specific points in a process?

    Hi,
    Using JDBC connection objects to manage transactions is feasible only in straightforward cases where you have more than one access to the SAME database (and in the same connection scope).
    If you want to be able to do rollback across more than one database (or even across different systems like a database and a queue) then you need to use the JTA facility.
    Hope that helps,
    Guy
    http://www.atomikos.com

  • Flex Data Services JOTM, JTA and JMX downloads

    I am not a Java developer. I am an Information Architect/UI
    Designer and up until a few months ago, I designed GUIs using MS
    Studio.Net -- Tomcat is a little different IIS, to say the least.
    =)
    I have downloaded the trial software of Flex Builder 2 and
    Flex Data Services to test it with intent to purchase.
    I was getting real happy with Flex Builder 2. Breezing
    through the "Getting Started" and all the tutorials. Absolutely
    Love it.
    Then along comes Flex Data Services. This application has
    bought me to a screeching halt.
    I've downloaded the files according to the instructions at:
    http://www.adobe.com/support/documentation/en/flex/2/install.html#flexj2ee.
    I placed the files in my webapps directory running on tomcat.
    However, according to the instructions at:
    http://www.adobe.com/support/documentation/en/flex/2/install.html#tomcat,
    I need to download additional applications in order to
    correctly use FDS. I have tried to download the JOTM 2.0.10.tgz
    from
    http://forge.objectweb.org/project/download.php?group_id=19&file_id=3926
    without success. When I try to unzip the file (I am running
    Windows XP Professional), I get the following error:
    "Error reading header after processing 0 entries."
    I've tried to download three different versions of JOTM, no
    luck. Our Java developer suggested that I save the "tar" file as a
    "zip" file and try to open it after download. However, when I try
    to open the archive in WinZip it returns this error:
    "Cannot open file: it does not appear to be a valid archive.
    If you downloaded this file, try downloading the file again."
    Both of these errors occur when trying to open the downloaded
    JOTM 2.0.10.tgz and JOTM 2.0.8.tgz files.
    How can I get these applications? Has anyone had any success
    in downloading these files from:
    http://forge.objectweb.org/project/showfiles.php?group_id=19&release_id=1024
    The downloaded archive files are empty. I can not run any of
    the Data Service samples.
    When I tried at:
    http://localhost:8080/samples/dataservice/flexcab/flexcabDispatcher.mxml
    A service error prompt returns: "Unable to access
    UserTransaction in Dataservice".
    I'm assuming this is because the JOTM (et. al) is not on my
    box, because the archive is empty when I try to open it in WinZip.
    Also, while I was reading the installation instructions for
    Tomcat at:
    http://www.adobe.com/support/documentation/en/flex/2/install.html#tomcat
    it seems pretty complicated for a non-Java programmer to
    understand. I asked one of our 6-year veteran Java developers here
    to help me with this and he said it was a pretty a complicated
    process for someone w/o Java programming experience. I thought it
    was geared towards front-end developers. But he did say that if I
    can't download the JOTM, I won't be able to do whatever it is that
    Flex Data Services is supposed to do. I say the latter because I am
    still in the "Getting Started" manual going through the last of the
    tutorials (which is the Flex Data Services distributed application
    tutorial) before I start reading "Using Flex", so I'm not really
    sure what lessons I will be doing that require FDS to work
    correctly on my box.
    Do I really need the FDS to build interactive applications in
    Flex Builder?
    I appreciate your answers. Thanks in advance.

    I agree with you about the process of getting FDS installed
    and working. I recommend that you try Christophe Coenraets FDMS
    tutorial. The JOTM files are in "tar" format, and so I think you'll
    have to extract them using a "tar" utility. This is included with
    any Unix variant, and so I asked someone at work to extract the
    files; on Windows I think you'll have to find a free "tar" program.
    I downloaded jotm-2.0.10.tar from the JOTM Sourceforge. Use
    parameters "-xf" if the tar file is not compressed, or "-zxf" if it
    is compressed. Good luck!

  • JTA and Oracle 8.1.6

              Newbie question.
              We're using Weblogic 6.1 sp2 with Oracle 8.1.6.
              What are my options for JDBC drivers to support JTA for CMT with our EJB's?
              Thanks
              

    Hi John,
              You should be able to use Latest Oracle 8.1.7 thin driver/XA or WebLogic
              jDriver.
              sree
              "John Hufnagle" <[email protected]> wrote in message
              news:3ce913fc$[email protected]..
              >
              > Newbie question.
              > We're using Weblogic 6.1 sp2 with Oracle 8.1.6.
              > What are my options for JDBC drivers to support JTA for CMT with our
              EJB's?
              > Thanks
              >
              

  • WLS JTA and  JMS

    Hi,
              I would like to know, whether the WLS TransactionManager can do the
              following,
              1. within a single unit of work using Bean managed transactions eg.
              pseudo code,
              txn.begin();
              for loop = 1 to n
              msg.send();
              txn.commit();
              I cannot get this to work with MQSeries JMS.
              Please can you explain how the TransactionManager works.
              Is the TransactionManager able to support concurrent transactions?
              If not how do you synchronize calls to the TransactionManager.
              Thank you in advance!
              Regards
              Suren
              

    Hi,
              I would like to know, whether the WLS TransactionManager can do the
              following,
              1. within a single unit of work using Bean managed transactions eg.
              pseudo code,
              txn.begin();
              for loop = 1 to n
              msg.send();
              txn.commit();
              I cannot get this to work with MQSeries JMS.
              Please can you explain how the TransactionManager works.
              Is the TransactionManager able to support concurrent transactions?
              If not how do you synchronize calls to the TransactionManager.
              Thank you in advance!
              Regards
              Suren
              

  • JTA Transaction and CUrrent Session

    We have the following problem. We configured hibernate with
    jta and when we execute a simple code that performs some hibernate
    queries we get the following error:
    "org.hibernate.LazyInitializationException: could not
    initialize proxy - the owning Session was closed"
    We discovered that if we leave the session opened the error
    disapears, but on the long run this crashes the server throwing a
    JDBC connection error.
    We tried to use getCurrentSession() instead of opening the
    session manualy but in this case we get the following error:
    "org.hibernate.HibernateException : Unable to locate current
    UserTransaction"
    This its quite strange because the current session should be
    bound to the current user transaction and its seems to us that our
    hibernate cfg file its ok.
    I´am posting part of my hibernate cfg file and the code
    that I execute.
    hibernate.cfg.xml
    <hibernate-configuration>
    <session-factory name="java:/hibernate/SessionFactory">
    <property
    name="hibernate.connection.datasource">java:fiap</property>
    <property
    name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <!-- Enable Hibernate's automatic session context
    management -->
    <property
    name="hibernate.current_session_context_class">jta</property>
    <property
    name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactor y</property>
    <property
    name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransact ionManagerLookup</property>
    <property
    name="jta.UserTransaction">java:comp/UserTransaction</property>
    <!-- <property
    name="connection.release_mode">after_statement</property>
    -->
    <!-- <property
    name="hibernate.transaction.flush_before_completion">true</property>-->
    <property
    name="hibernate.transaction.auto_close_session">true</property>
    and my java Code:
    try {
    tx = HUtil.getTx(); //JNDI lookup
    tx.begin();
    session = HUtil.getSessionFactory().getCurrentSession();
    //JNDI Lookup
    //session = HUtil.getSessionFactory().openSession();
    Query query = session.createQuery("from Persona where
    username = ?");
    query.setString(0, userName);
    persona = (Persona) query.uniqueResult();
    query = session.createQuery("from Festival where id = ?");
    query.setInteger(0, idFestival);
    festival = (Festival) query.uniqueResult();
    if (persona != null && festival != null) {
    query = session.createQuery("from Inscripcion where
    inscribeA = :persona " +
    "AND inscriptosEn = :festival");
    query.setParameter("persona", persona);
    query.setParameter("festival", festival);
    inscripcion = (Inscripcion) query.uniqueResult();
    return inscripcion;
    } catch (Exception e) {
    e.printStackTrace();
    throw e;
    } finally {
    tx.commit();
    //session.close();
    thanks

    The scenario you described is typical ... "If a client calls m1" ... there are 2 cases:
    (1) the client is already in a trans
    (2) not (1)
    Let (1). This is the case of a Client Controlled Transaction ... etc ... when s1 is called it begins a transaction in the client transactional context ... hence s1 can't call a kind of roolback but can force the rollback of the global transaction marking EJBContext.setRollbackOnly() ... s2 uses the same transactional context ... anayway the client is the only one that can commit. This happens because of "transaction required" as the transaction attribute, that in this case forces a flat transaction model. Different is the case if you uses "requiredNew" --> nested trans model ...
    (2) is the same of (1) except that the trans starts at application tier.
    "I still have one doubt. Wouldn't the stateless session bean loose the transaction context once I exit the second stateles session bean's method? Isn't that what stateless means? "
    No:
    stateless doesn't stay for the transaction context but for the conversational state with the client ... that is serializable ... it makes the beans more poolable ... that the stateful session bean has
    bye

  • JMS and JTA XA

    Hello,
    I an new to JTA and want to understand the intended behavior of a JMS provider that must support JTA XA.
    Following is scenario
    1. Client connects to a XA compliant JMS provider and an XA compliant JDBC resource and initiates a global transaction
    2. Publishes 2 messages.
    3. Receives 3 messages
    4. Does a SYNCHRONOUS request-reply
    5. Does a JDBC database update that fails and trasnaction must be rolled back.
    Here are my questions -
    1. When should published documents be released to any subscribers? At the end of transaction when commit occurs?
    2. Biggest confusion - What happens to SYNCHRONOUS request/reply messages? What if these messages were processed by another client and resulted in a database update. How can I bring that client with in scope of transaction. Should provider deliver these messages also at the end of transaction?
    Thanks and regards

    Andreas,
    Is "synchronous request-reply not permitted as part of
    transactions" behavior prohibited with JMS or JTA
    specifications? JMS. It's quite logical too. You can't get a reply on a request you haven't sent yet since the tx isn't committed...

  • Problem with "package-info.java" using EJB 3.0 and OC4J

    Hi all.
    I already posted this question on JDeveloper forum, but didn't get any answer,
    so I'll try posting here.
    Anyway, I'm new both to JDeveloper and J2EE,
    so I'm trying out examples for EJB 3.0, and I got stuck at "Use Security Annotations with EJB 3.0"
    (http://www.oracle.com/technology/tech/java/oc4j/ejb3/howtos-ejb3/howtoejb30security/doc/how-to-ejb30-security-ejb.html).
    Example code is working perfectly, if one builds it using Ant, but I'm importing all examples into JDeveloper (or at least I'm trying to :))
    JDeveloper can't build file "package-info.java" containing following code:
    @javax.annotation.security.SecurityRoles(roleNames={"superuser", "user"})
    package oracle.ejb30;I'm getting following output in "Compiler - Log" window:
    Error(2,1): 'class', 'interface', or 'enum' expected.
    Help much appreciated...
    platform used:
    Windows XP SP2
    JDeveloper Studio (Version 10.1.3, Build 3412)
    JDK 1.5_06
    OC4J 10.1.3 developer preview 4 (standalone version)

    Since you're using EJBs, you can use JTA and can skip the getTransaction() calls. If you want to use getTransaction().begin() and commit(), then make sure that your EntityManager is resource-local. The configuration for this is in persistence.xml. Set a transaction-type of RESOURCE_LOCAL rather than JTA.

  • EJB 3.0 and Oc4J::: IllegalStateException

    Hello,
    I am trying to access a method in my EJB3.0, which basically does data update, but I am getting IllegalStateException, any idea, why am I getting that exception.
    javax.ejb.EJBException: java.lang.IllegalStateException: Cannot use resource level transactions with a container managed EntityManager; nested exception is:
         java.lang.IllegalStateException: Cannot use resource level transactions with a container managed EntityManager; nested exception is: oracle.oc4j.rmi.OracleRemoteException: java.lang.IllegalStateException: Cannot use resource level transactions with a container managed EntityManager; nested exception is:
         java.lang.IllegalStateException: Cannot use resource level transactions with a container managed EntityManager
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.rmi.RMICall.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMICall.java:109)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.rmi.RMICall.throwRecordedException(RMICall.java:125)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:517)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:461)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.ejb.StatefulSessionRemoteInvocationHandler.invoke(StatefulSessionRemoteInvocationHandler.java:31)
         at __Proxy1.updateCanAssignInformations(Unknown Source)
         at gov.nih.eta.beantier.etaruleservice.CanAssignmentServiceAdapter.updateCanInformations(CanAssignmentServiceAdapter.java:37)
         at gov.nih.eta.webtier.actions.ICCanAssignmentAction.execute(ICCanAssignmentAction.java:223)
         at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
         at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
         at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
         at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
         at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
         at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
    My bean method:
    public void updateCanAssignInformations(List<CanAssignmentsEntity> canAssignmentsEntityList)
              System.out.println("Calling EJB method>>>>>>>>>>>>>>>");
              CanAssignmentsEntity canAssignmentsEntity = null;          
              for(int i=0; i<canAssignmentsEntityList.size(); i++)
                   System.out.println("Step0");
                   canAssignmentsEntity = (CanAssignmentsEntity)canAssignmentsEntityList.get(i);
                   em.getTransaction().begin();
                   System.out.println("Step1");
                   CanAssignmentsEntity canAssignmentsEntity1 = em.find(CanAssignmentsEntity.class, canAssignmentsEntity.getCanAssignmentEntityPK());
                   System.out.println("Step2");
                   canAssignmentsEntity1.setCanAssignmentEntityPK(canAssignmentsEntity.getCanAssignmentEntityPK());               
                   canAssignmentsEntity1.setCreatorId("dasra");               
                   java.util.Date today = new java.util.Date();
                  java.sql.Date dateToday =  new java.sql.Date(today.getTime());             
                   canAssignmentsEntity1.setCreatorDate(dateToday);               
                   canAssignmentsEntity1.setRfaNumberInclusion(canAssignmentsEntity.getRfaNumberInclusion());               
                   canAssignmentsEntity1.setMechanismCodeInclusion(canAssignmentsEntity.getMechanismCodeInclusion());               
                   canAssignmentsEntity1.setApplTypeInclusion(canAssignmentsEntity.getApplTypeInclusion());               
                   canAssignmentsEntity1.setActivityCodeInclusion(canAssignmentsEntity.getActivityCodeInclusion());
                   System.out.println("Step1");
                   em.getTransaction().commit();
         }

    Since you're using EJBs, you can use JTA and can skip the getTransaction() calls. If you want to use getTransaction().begin() and commit(), then make sure that your EntityManager is resource-local. The configuration for this is in persistence.xml. Set a transaction-type of RESOURCE_LOCAL rather than JTA.

  • Cache Synchronization with JMS and a Message Driven Bean (MDB)

    If I understand correctly, Toplink ueses the following configuration info to find the target to publish its session messages to a JMS server (having its URL as below) which provides the JNDI service that Toplink needs to look up the topic:
    <cache-synchronization-manager>
    <clustering-service> oracle.toplink.remote.jms.mdb.JMSPublishingOnlyClusteringService
    </clustering-service>
    <should-remove-connection-on-error>false</should-remove-connection-on-error>
    <!-- both of the following tags are user specified and must correspond to -->
    <!-- the settings that the user has made, manually, to the JMS Service -->
    <jms-topic-connection-factory-name> jms/TopLinkTopicConectionFactory
    </jms-topic-connection-factory-name>
    <jms-topic-name>jms/TopLinkCacheSynchTopic</jms-topic-name>
    <!-- both of the following tags will be required if OracleAS TopLink -->
    <!-- is not running in the same JVM as the JNDI service that is hosting the JMS Topic -->
    <naming-service-url>ormi://localhost:23791</naming-service-url>
    <naming-service-initial-context-factory> com.evermind.server.rmi.RMIInitialContextFactory </naming-service-initial-context-factory></cache-synchronization-manager>
    The MDB also uses the same JNDI service provided by the JMS server to listen to the topic which is named in the ejb-jar.xml file:
    <enterprise-beans>
    <message-driven>
    <display-name>TopLink clustering MDB</display-name>
    <ejb-name>TopLinkClusteringMDB</ejb-name>
    <ejb-class>com.mycompany.mdb.ClusteringMDB</ejb-class>
    <transaction-type>Container</transaction-type>
    <message-driven-destination> <destination-type>javax.jms.Topic</destination-type>
    </message-driven-destination>
    <env-entry>
    <description>TopLink session name</description>
    <env-entry-name>tl_session_name_for_mdb</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>Employee_Session</env-entry-value>
    </env-entry>
    <resource-ref> <description>description</description>
    <res-ref-name>jms/TopLinkTopicConectionFactory</res-ref-name>
    <res-type>javax.jms.TopicConnectionFactory</res-type>
    <res-auth>Application</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    <resource-env-ref>
    <resource-env-ref-name> jms/TopLinkCacheSynchTopic</resource-env-ref-name>
    <resource-env-ref-type>javax.jms.Topic</resource-env-ref-type> </resource-env-ref>
    </message-driven></enterprise-beans>
    To do this, the EJB container that hosts the above MDB needs to be configured to know where the JMS server is by using the above URL same as in the Toplink sessions.xml file.
    I am not clear that who provides the JNDI service for the Toplink session name lookup used by the MDB:
    // Obtain the Session name configured in the environment variable
    String sessionName = (String) myEnv.lookup(TOPLINK_SESSION_NAME);
    session = SessionManager.getManager().getSession(sessionName);
    so that the MDB can find the currently running Toplink session and communicate with it.
    Can anybody help answer my above question and correct my understandings?
    Many thanks!

    Although TopLink is running in the application server’s VM, the only notable integration points with the server are for JTA and user-defined data sources. All of the work performed to get a session via SessionManager occurs solely within TopLink. When the call is made to retrieve a session, you aren’t getting the ‘active’ session identified by “Employee_Session” that is registered with the application server, rather a new session is created using the definition that exists for “Employee_Session” in sessions.xml.
    When the call ‘session = SessionManager.getManager().getSession(“Employee_Session”)’ is made, the SessionManager simply looks for sessions.xml at the root level of its deployed jars or classpath, then looks for the “Employee_Session” tag within sessions.xml. If a session exists in the file with that name then a TopLink session object is created and returned.
    Note that setting an environment entry as mentioned above simply allows for the session name to be declared dynamically. The call to ‘myEnv.lookup(“tl_session_name_for_mdb”)’ simply asks the bean’s environment for the <env-entry-value> that matches the <env-entry-name>. That string is then used in SessionManager (no different than a hard coded value would be) to identify the session in sessions.xml that is to be loaded.
    I hope this makes sense.

  • JTA Transaction--please help-----Xid not valid

    HI,
    I am writing a small application which i am posting at the end.This is decription of my application.I am writing a jsp.Later on i will be using in some other way.
    I am using Oracle XA implementation to communicatewith my RM which oracle8.1.7 .
    I am creating two XAConnection with two data instances 'test' and 'test3' .These two reside on my local machine in the same database server.
    With the code which i am sending you i have tried two cases.
    First Case
    1)i use only one XAConnection object of say 'test'.
    2)enlist its XADataSource with my transaction Object
    3) get two connection objects and execute two sql's on themMy code works fine and maintains the transaction.
    Second Case
    1) I use create two XAConnection objects. one of 'test' and other of 'test3'.
    2) enlist their XAResources with transaction object.
    3) Now i take one connection from each of XAConnection and execute two sqls, oneon each of them.
    It gives me exception while enlisting second XAResource with transaction objeectsaying that "The Xid is not valid".
    below is the stackTrace.
    javax.transaction.SystemException: start() failed on resource 'oracle.jdbc.xa.client.OracleXAResource':XAER_NOTA : The XID is not valid
    oracle.jdbc.xa.OracleXAException at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:483)
    at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:190)
    at weblogic.transaction.internal.ServerResourceInfo.start(ServerResourceInfo.java:1165)
    at weblogic.transaction.internal.ServerResourceInfo.xaStart(ServerResourceInfo.java:1108)
    <----------------------CODE------------------------------------------------------>
    <html>
    <body bgcolor=tan>
    <%@page session="true" %>
    <%@page import="java.util.Hashtable,java.sql.*,javax.naming.*,javax.transaction.*,javax.sql.*,oracle.jdbc.xa.client.OracleXADataSource,javax.rmi.PortableRemoteObject,javax.transaction.xa.XAResource" %>
    <%!
    private static XAConnection getFirstXAConnection() throws java.sql.SQLException{
         OracleXADataSource oxadsFirst = new OracleXADataSource();
         String urlFirst = "jdbc:oracle:thin:@70.7.51.80:1521:test";
         oxadsFirst.setURL(urlFirst);
         XAConnection xaConnectionFirst = oxadsFirst.getXAConnection("scott","tiger");
    return xaConnectionFirst;
    private static XAConnection getSecondXAConnection() throws java.sql.SQLException{
              OracleXADataSource oxadsSec= new OracleXADataSource();
              String urlSec = "jdbc:oracle:thin:@70.7.51.80:1521:test3";
              oxadsSec.setURL(urlSec);
              XAConnection xaConnectionSec = oxadsSec.getXAConnection("scott","tiger");
    return xaConnectionSec;
    %>
    <%
    Context ctx = null;
         Hashtable ht = new Hashtable();
         ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
         ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
         try{
              ctx = new InitialContext(ht);
              //javax.transaction.UserTransaction transaction = (javax.transaction.UserTransaction)ctx.lookup("java:comp/UserTransaction");
              System.out.println("Before Lookup JNDI UserTransaction and TransactionManager......................");
              //javax.transaction.UserTransaction userTx = (javax.transaction.UserTransaction)ctx.lookup("javax.transaction.UserTransaction");
              javax.transaction.TransactionManager transactionManager = (javax.transaction.TransactionManager)ctx.lookup("javax.transaction.TransactionManager");
              System.out.println("After Lookup TransactionManager......................");
    try{
                   transactionManager.begin();
                   Transaction transaction = transactionManager.getTransaction();
                   System.out.println("Transaction Object ----------------------------->"+transaction);
    XAConnection xaConFirst = getFirstXAConnection();
    XAResource xaResourceFirst = xaConFirst.getXAResource();
    System.out.println("xaResourceFirst Object ----------------------------->"+xaResourceFirst);
    XAConnection xaConSecond = getSecondXAConnection();
    XAResource xaResourceSecond = xaConSecond.getXAResource();
    System.out.println("xaResourceSecond Object ----------------------------->"+xaResourceSecond);
    if(!xaResourceFirst.isSameRM(xaResourceSecond) )
    System.out.println("<-----------------BOTH THE RESOURCES ARE NOT SAME SMAE SAME----------------------------->");
    boolean firstEnlistBool = transaction.enlistResource(xaResourceFirst);
    System.out.println("firstEnlistBool ----------------------------->"+firstEnlistBool);
    boolean secondEnlistBool = transaction.enlistResource(xaResourceSecond);
    System.out.println("secondEnlistBool -------------------------> "+secondEnlistBool);
    java.sql.Connection firstConn = xaConFirst.getConnection();
    Statement stmt = firstConn.createStatement();
    stmt.executeQuery("insert into dept values(60,'MARKETING','NEW DELHI')");
    java.sql.Connection secondConn = xaConSecond.getConnection();//xaConFirst.getConnection();//
    stmt = secondConn.createStatement();
    //stmt.executeQuery("insert into account values(20,20)");
    stmt.executeQuery("insert into salgrade values(10,10,10)");
    if(Status.STATUS_ACTIVE == transactionManager.getStatus() )
    System.out.println("Before committing status "+transactionManager.getStatus() );
    transactionManager.commit();
    System.out.println("After committing");
              } catch(SQLException sqlE){
                        sqlE.printStackTrace();
                        catch(Exception e){
                                            e.printStackTrace();
         } catch (Exception ex) {
              ex.printStackTrace();
              finally {
                   try {
                        ctx.close();
                        catch (Exception e) {
                             e.printStackTrace();
                   } // close finally
    %>
    <form method="post">
    <input type="submit" name="submit" value="Call Transaction Bean">
    </form>
    </html>
    <-------------------------------------------------------------------------------->
    please help in this..I am stuck with this and dont kow how to move ahead to remove this problem..
    Best Regards
    Akhil Nagpal

    Hi,
    Hi Vicky,
    I think we are in different time zones. I am south
    korea.I have tried your suggestion but it gives me
    the same exception.Yes ,there is a difference of 3.5 hours , I am in India(Mumbai).
    This is what i am trying to achieve.
    My aim is to create some aplication to which i can
    register my XADataSources and this application should
    be able to handle the distributed transactions among
    them.I will be using the TransactionManager of some
    application server.SO i am using weblogic7.0.
    For the testing purpose i have creaed a jsp as i
    i posted the code. I am very new to this JTA and may
    be i am doing wrong.Can you help me this but putting
    insights into your experience may be that will
    increase my enthusiasm :-) ....
    please help me in this.
    I am extracting the following from the docs
    public interface TransactionManager
    The TransactionManager interface defines the methods that allow an application server to manage transaction boundaries.
    public interface UserTransaction
    The UserTransaction interface defines the methods that allow an application to explicitly manage transaction boundaries
    So as per your specs I can understands your application is trying to explicitily control the boundaries of the transaction, so you should use the UserTransction instance to begin the Transaction.My understanding says the TransactionManager will come in picture for declarative transaction and UserTransaction for the your case.I think you have tried that , I would have tried this out here but I dont work on weblogic.Do the things cooly and try to understand the concept.Let me know of the results.
    Regards
    Vicky

  • JPA and Entity manager.

    Hi all,
    I have a "simple" question:
    Should I create a class to manage entity manager and entity manager factory on JPA2?
    Why do I ask that? Because I read on J2EE tutorial:
    With a container-managed entity manager, an EntityManager instance’s persistence context is automatically propagated by the container to all application components that use the EntityManager instance within a single Java Transaction Architecture (JTA) transaction.
    To obtain an EntityManager instance, inject the entity manager into the application component:
    @PersistenceContext
    EntityManager em;
    I'm using JSF2, JPA2, JTA and Glassfish3.1 on the NetBeans 7.0.1.
    The wizard that creates the JSF's pages from entity class does a good work but I have some problem in the other classes.
    When I call EntityManager it returns null!
    The strange thing is that it works properly the first time, when I recall the EntityManager from another xhtml page and from another class the entity manager returns NULL!
    So I would understand if the creation of a class for manage the EntityManagerFactory and EntityManager could help me.
    Thank you for your future help!

    Filippo Tenaglia wrote:
    Hi all,
    I have a "simple" question:
    Should I create a class to manage entity manager and entity manager factory on JPA2?That question is far from complete, as the answer to this one is "depends on what you want to do!"
    Why do I ask that? Because I read on J2EE tutorial:
    With a container-managed entity manager, an EntityManager instance’s persistence context is automatically propagated by the container to all application components that use the EntityManager instance within a single Java Transaction Architecture (JTA) transaction.
    To obtain an EntityManager instance, inject the entity manager into the application component:
    @PersistenceContext
    EntityManager em;
    Given this information...
    I'm using JSF2, JPA2, JTA and Glassfish3.1 on the NetBeans 7.0.1.That answer to your question is "NO", because you have a container available to you that can do the work (Glassfish). It makes no sense using Glassfish and then purposely ignoring the features it has to offer.
    Lets get back to basics: you are doing something wrong here. You have to figure out what, you can only do that if you keep studying and getting a more complete understanding. If you are having trouble realizing that, perhaps you should start over without the help of any wizard at all; wizards are only useful when you are already experienced, right now the fact that code is generated is hindering you a lot because you will have a strong impulse to believe there can be no mistake; unfortunately there is no such safety net. The fact that you used the word "weird" is enough proof of this by the way. There is nothing weird here, just a mistake being made that has to be corrected.
    And for the future: what IDE (Netbeans in your case) you use to develop really makes absolutely no difference at all. What is more interesting is which version of Java your are using, which can likely be Java 6 or Java 7 nowadays.

Maybe you are looking for

  • Review Widget Error with Portrait Photos

    When previewing my review widgets on the iPad, all of the questions with photos in portrait orientation are messed up even though they look fine when viewed in ibooks author. Even when I delete the photo completely and just have the words, it is stil

  • Alerts on mapping error from BPM

    In my BPM, when I use 'Throw Alert' via control step before transformation, it creates an Alert. What I would like to do is to Throw Alert when there is a mapping error. And in order to do this, I created an exception block within my transformation s

  • Oracle 11g Instant Installer and NLS_LANG

    Hi, could anybody tell me where I can set the NLS_LANG on Win7? I use the Instant Installer and I dont have any registry entry... Markus Edited by: user5278245 on 23.05.2012 16:22

  • Google Search embedded in an HTML region

    Hello, I tried to embed the standard Google search engine code (see below) into an HTML region within the HTML DB app, but upon hitting "submit" I get an error because the HTML DB engine tries to process the form post, instead of allowing a redirect

  • SCSM 2012 console crashes

    Hello ,    SCSM console crashes when i try to open the Service requests forms.It happens only when i open the closed requests.Below is the error. Description:   Stopped working Problem signature:   Problem Event Name: CLR20r3   Problem Signature 01: