Distributed transactions and 2-phase commit in a SAP Netweaver environment

Hello,
I am a Java architect., I don't know very much the SAP technologies. I tried to found on forums or technical papers if SAP does support distributed transactions and two-phase commit, it's not clear. I found something on SAP WAS but my project is using a  SAP PI 7.0 and I cannot find anything on the subject.
My goal is to include a SAP server (via PI 7.0) in a distributed transaction handled by a J2EE ESB (Oracle, ex-BEA Aqualogic) based on XA capabilities.
Does anyone have experience or feedback on this topic ?
Thanks.

Hi,
Do you know this white paper ?
[Distributed Transaction and 2 phase commit|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3732d690-0201-0010-a993-b92aab79701f]
Regards,
Olivier

Similar Messages

  • XDK and 2 Phase Commit

    Hi guys,
    I am taking messages off an MQ Series Queue and using
    DBMS_XMLSave.insertXML(this function does an implicit commit) to
    insert into a table.
    The insert fails with the Error code 02070: Database does not
    support commit in this context.
    This seems due to the fact that the dequeue has not been
    comitted. I am trying to do this to avoid losing any message if
    the is an error or system failure.
    It works if dequeue is commited.
    Does XDK support 2 Phase commit or is there a patch that allow
    this?
    Thanks
    Abbey

    Hi,
    Do you know this white paper ?
    [Distributed Transaction and 2 phase commit|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3732d690-0201-0010-a993-b92aab79701f]
    Regards,
    Olivier

  • Distributed Transactions and Linked Servers

    I'm somewhat of a novice with SQL Server but I'm learning rapidly from an application I'm developing that uses SQL Server very heavily. In conjunction with the development of this application, I have 3-4 systems set up running SQL Server and I am using those
    systems to develop the database that will ultimately support the application. I decided to try to use linked servers because I am moving data back-and-forth among the different servers frequently and I ran into some consequences that I wasn't expecting.
    I was doing a simple delete query on one of the servers (Delete from TableName Where ...) and I was expecting, of course, that it would only impact the server I was running it on; however, when the query finished after running for a long time, it was apparent
    that SQL Server had automatically escalated that simple delete query into a distributed transaction and applied it to all four of the linked servers I had defined.  I was totally surprised by that and it took some time to recover the data that was inadvertently
    lost on the other servers.
    I want to ensure that this doesn't happen again without me expecting it - I think the right way to prevent this from happening is to run the following stored procedure:
    EXEC sp_serveroption 'servername', 'remote proc transaction promotion', 'false';
    Can someone please verify that this assumption is correct and will prevent SQL Server from automatically creating distributed transactions impacting multiple servers?
    Thanks,
    Chuck

    Hello,
    Based on your description, it seems that when you connect to a SQL Server database and execute a DELETE statement to delete a recode on a table, and then the same recode were delete in the linked server which has the same table.
    As pre my understand, the statement executed on one server will not  apply to the linked servers unless you specify the logic yourself in the application. For example, you use dynamic query and exec the query synchronously on  linked servers.
    What's more, did you specify replication between this linked server?
    If I have any misunderstanding, please let me know.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here.
    Fanny Liu
    TechNet Community Support

  • Archiving  and Deleting of XML Messages in SAP NetWeaver PI 7.31 single stack

    Hello my XI friends!
    Need step by Step Guide to Archiving
    and Deleting of XML Messages in
    SAP NetWeaver PI 7.31 single stack
    Similar to these instructions
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e0afdd69-a8a7-2d10-7e9a-cbf6fa21c5a7?quicklink=index&overridelayout=true
    Regards,
    Rinaz

    Please check the below blog  for archiving java only-(XMLDAS)
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2011/11/16/aae-archiving-in-sap-pi-711-with-xmldas
    For deletion there is standard delete job..
    https://help.sap.com/saphelp_nw73ehp1/helpdata/en/48/b2e0036b156ff4e10000000a42189b/frameset.htm
    Message was edited by: Hareesh Gampa

  • SAP Transaction in Two phase Commit ?

    Hi all,
    When we make a connection to SAP system from .NET application using .NET connector, we can make calls to transactional BAPI/RFC’s. But is there any way in which we can make SAP transaction take part in MS DTC (Microsoft Distributed Transaction Coordinator) transactions?
    We want to implement a two phase commit and hence this question. Please let us know if you are aware of any mechanism using which we can implement a two phase commit.
    The call scenario is described below:
    TransactionScope
    1.     SQL_StoredProc1();
    2.     SQL_StoresProc2();
         10.           SAP_TransactionBAPI();
         11.          SQLStoredProcn();
          12.           SQLTransaction_Commit();
          13.      SAPTransaction_Commit();
    Exception ()
    SQLTransaction_Rollback();
    SAPTransaction_Rollback();
    In the above case all the statements have to be executed successfully or they have to be rolled back. Let’s think of the situation where all the statements up to line 13 have been executed successfully, but there was a failure during the commit of SAP, and then we have to rollback the SQL transaction also which is already committed.
    This situation can be handled if and only if SAP transaction manager follows XA transaction protocol and it can include itself in MSDTC. So that every transaction manager votes for the commit (it can be called half commit) if the transaction is successful otherwise all the transactions should be rolled back.
    Can anybody tell me the way to include SAP transaction manager in MSDTC if it at all possible?

    Hi Saket,
    I did  not understand much of your query but just wanted to know how are you making a connection to the backend here?
    If using DataSources and if the datasource is configured directly in the EP server (using Visual Administrator), you have an option of the required 2-way commit.
    The datasource takes care of it directly. Apart from this, the datasource will also take cre of the connection pooling.
    Hope this helps.
    Awaiting Reply.
    Warm Regards,
    Ritu

  • Need basic primer on distributed transactions and java

    Hello,
              I am new to distributed transactions in Java...
              I am wondering if there is useful link that will
              explain the basics....
              How is it supported in J2EE, etc.?
              How is it supported in WLS?
              How does 2-phase commit work, etc.?
              Thanks,
              Jason
              

    Hi,
              I fond the following a good clear, concise (non vendor specific) intro to
              transactions.
              http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction.html
              Cheers,
              SB
              "Jason Rosenberg" <[email protected]> wrote in message
              news:3eba8128$[email protected]..
              > Hello,
              >
              > I am new to distributed transactions in Java...
              >
              > I am wondering if there is useful link that will
              > explain the basics....
              >
              > How is it supported in J2EE, etc.?
              > How is it supported in WLS?
              > How does 2-phase commit work, etc.?
              >
              > Thanks,
              >
              > Jason
              >
              >
              

  • Weblogic 5.1, Distributed Transaction and Oracle Database Link

    We are planning to add a new functionality to run in Weblogic server and it
    needs to update tables in two different Oracle databases. Since we are using
    Weblogic 5.1 and it is unrealistic to upgrade to 6.1 in short term, we have
    to deal with the fact that distributed transaction is not supported by JTS
    on 5.1.
    One workaround we can think of is to utilize Oracle database link. Instead
    of having two connection pools, the application talks to only one database
    and access the tables on the other ones through Oracle database link.
    Therefore, when a session bean tries to update two tables on database 1 in
    one transaction, one of the tables is just a link to the other database. We
    hope that even though distributed transaction is not supported by JTS in
    Weblogic 5.1, but since it is supported by Orable, it would work.
    Do you think the above workaround would work? Does anyone have experience on
    something like that?
    Thanks in advance,
    David Chen
    [email protected]

    Hi. You should be able to use any JDBC driver with WebLogic 5.1.
    It may be the JVM that complains, if you use too old a JVM...
    Joe Weinstein at BEA Systems

  • Using XA Drivers and two phase commit in WLS6.0 sp2

              Hi,
              I'm trying to do a distributed transaction with the oracle thin driver. Classes12.zip
              and oracle 8.1.7 with Jserver installed.
              Weblogic6.0
              When i try to do a ejbCreate the following error is thrown now if i remove the
              transaction context the error goes.
              Here is the config file info.
              <JDBCConnectionPool CapacityIncrement="1" DriverName="oracle.jdbc.xa.client.OracleXADataSource"
              InitialCapacity="1" MaxCapacity="5" Name="TestPool1" Properties="user=sys;password=change_on_install;url=jdbc:oracle:thin:@192.168.168.129:1521:ORCL"
              RefreshMinutes="0" ShrinkPeriodMinutes="15" ShrinkingEnabled="true" Targets="examplesServer"
              TestConnectionsOnRelease="false" TestConnectionsOnReserve="false"/>
              <JDBCTxDataSource EnableTwoPhaseCommit="true" JNDIName="TestPool1TX" Name="TestPool1TX"
              PoolName="TestPool1" Targets="examplesServer"/>
              ---------------------------- Here are the different errors i get when i try with
              different databases.
              java.sql.SQLException: ORA-29532: Java call terminated by uncaught Java exceptio
              n: java.lang.NullPointerException ORA-06512: at "SYS.JAVA_XA", line 0 ORA-06512:
              at line 1
              at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
              at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542) at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1311)
              at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:738 ) at
              oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.ja va:1313)
              at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.jav a:1232)
              at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement .java:1353)
              at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java:176 0) at
              oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme nt.java:1805)
              at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePrepar edStatement.java:322)
              at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat ement.java:366)
              at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:10 2) at
              weblogic.jdbc.jta.OracleXAResource.start(OracleXAResource.java:41)
              Would be very grateful for any help.
              Regards, kartik
              

              Make sure that:
              1. Your Oracle server is a 8.1.7 server. This is necessary for XA. Looks like
              you are already doing this.
              2. You do not have any Oracle 8.1.6 JDBC driver zip files in your path before
              the Oracle 8.1.7 one.
              Regards,
              Priscilla
              "kartikeyabisht" <[email protected]> wrote:
              >
              >Hi,
              >
              >I'm trying to do a distributed transaction with the oracle thin driver.
              >Classes12.zip
              >and oracle 8.1.7 with Jserver installed.
              >
              >Weblogic6.0
              >
              >When i try to do a ejbCreate the following error is thrown now if i remove
              >the
              >transaction context the error goes.
              >
              >Here is the config file info.
              >
              ><JDBCConnectionPool CapacityIncrement="1" DriverName="oracle.jdbc.xa.client.OracleXADataSource"
              >InitialCapacity="1" MaxCapacity="5" Name="TestPool1" Properties="user=sys;password=change_on_install;url=jdbc:oracle:thin:@192.168.168.129:1521:ORCL"
              >RefreshMinutes="0" ShrinkPeriodMinutes="15" ShrinkingEnabled="true" Targets="examplesServer"
              >TestConnectionsOnRelease="false" TestConnectionsOnReserve="false"/>
              >
              ><JDBCTxDataSource EnableTwoPhaseCommit="true" JNDIName="TestPool1TX"
              >Name="TestPool1TX"
              >PoolName="TestPool1" Targets="examplesServer"/>
              >
              >---------------------------- Here are the different errors i get when
              >i try with
              >different databases.
              >
              >java.sql.SQLException: ORA-29532: Java call terminated by uncaught Java
              >exceptio
              >n: java.lang.NullPointerException ORA-06512: at "SYS.JAVA_XA", line 0
              >ORA-06512:
              >at line 1
              >
              >at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114) at
              >oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
              >at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542) at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1311)
              >at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:738
              >) at
              >oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.ja
              >va:1313)
              >at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.jav
              >a:1232)
              >at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement
              >.java:1353)
              >at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java:176
              >0) at
              >oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
              >nt.java:1805)
              >at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePrepar
              >edStatement.java:322)
              >at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
              >ement.java:366)
              >at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:10
              >2) at
              >weblogic.jdbc.jta.OracleXAResource.start(OracleXAResource.java:41)
              >
              >-------------------------------------------------------------
              >
              >Would be very grateful for any help.
              >
              >Regards, kartik
              >
              

  • Distributed transactions and connection pooling

    Hi,
    We have a problem with the enlistment of connections in distributed transactions.
    The following very simple C# program does not work correctly (a simple form with one button and a class hosted in COM+). If you put a breakpoint on "cnOraTx.Close();" you will see that the inserted record is already visible in the database although the transaction has not commited yet.
    If you comment out the lines between //START and //END everything works as expected.
    Also, if we use "Pooling=false" in the connection string, everything works fine again, but since we are writing a web application, we really need the connection pooling.
    We are using ODP.NET 9.2.0.2.102 (I also tried with the ODP.NET 9.2.0.4.0 BETA) and an oracle 8.1.7 database.
    Best Regards,
    Piet
    private void button1_Click(object sender, System.EventArgs e)
    //When commenting the following lines the connection is enlisted in the distributed transaction
    //START
    OracleConnection cnOraTx;
    cnOraTx = new Oracle.DataAccess.Client.OracleConnection("Data Source=ECOMP532;User ID=USER;Password=PWD");
    cnOraTx.Open();
    cnOraTx.Close();
    cnOraTx.Dispose();
    //END
    OpenOraTransConn obj = new OpenOraTransConn();
    obj.Connect();
    //This class is going to be hosted within COM+
    [Transaction(TransactionOption.Required)]
    public class OpenOraTransConn: ServicedComponent
    private OracleConnection cnOraTx;
    private OracleCommand cmd;
    internal void Connect()
    cnOraTx = new OracleConnection("Data Source=ECOMP532;User ID=USER;Password=PWD");          
    cnOraTx.Open();
    cmd = new OracleCommand();
    cmd.Connection = cnOraTx;
    cmd.CommandText = "INSERT INTO SYSADM.PERSON (PE_KEY) VALUES(130000)";
    cmd.ExecuteNonQuery();
    cnOraTx.Close();
    cnOraTx.Dispose();
    ContextUtil.SetComplete();

    Hello:
    We are experiencing the exact same problem. INSERT, UPDATE or DELETE statements that should roll back because an exception is being thrown from inside our ServicedComponent-derived class (which is set to TransactionOption.Required and uses AutoComplete) are not -- and instead are being committed to the database.
    Were you able to figure out why this is happening, and what can be done to get around it? We too were able to avoid the problem by setting Pooling=False to our connect string, but for a variety of reasons we want to use connection pooling ...!

  • Download and install ADS on CE1 by SAP NetWeaver 7.01 ABAP Trial Version

    Hi,
    I came across many posts but no reply to a simple question: where can we download and how can we install ADS to run on CE1 and be used by SAP NetWeaver 7.01 ABAP Trial Version?
    Then I saw some postings where guys were asking particularities on this issue which means, I guess, that they have downloaded and installed the thing.
    Could you, please, provide some directions on this?
    Or, if it is not possible, I would like to know that too.
    Is there anyone who had success in doing this?
    Thanks!
    KR,
    Igor
    Edited by: Igor Barbaric on Oct 3, 2010 7:44 PM

    Hi Igor
    It seems, we have/had? similar problems.
    Did you get any infos how to install / run ADS on your CE1 / NW 7.01?
    I'm actually trying it with CE 7.2 and NW 7.02 trials.
    Until now without any success.
    Regards, Stefan

  • Retraction and STS in the new BI7 / SAP Netweaver

    Hi
    How the retraction and STS is relevant in the new BI7 / SAP Netweaver 2007 product for BI Inetgrated Planning. Any document on retraction and STS related to BI Integrated Planning
    G K Mohata
    [email protected]

    Hi...i think we have retractor programs similiar to BPS.
    STS will not work with IP. You need to use BPS for this.

  • MDB Distributed transaction and stored procedure rollback

    Hi All,
    I am developing an asynchronous application using MDB. My application flow is as follows:
    1. From MDB onMessage i am calling another method MEthodA that
    a. calls a simple pojo1 where I am getting a Connection on XA enable datasource1 and executing Stored Procedure1 of DatabaseSchema1. In Stored Procedure1 I have some inner savpoints and rollback. No commit is inside Stored Procedure1 .
    b. In that pojo withput commiting m closing the connection and coming back in MethodA.
    c. Again from MethodA m calling an different pojo2 where I am getting a new Connection on XA enable datasource2 and executing Stored Procedure2 of DatabaseSchema1.In this pojo also without commiting m closing the connection and coming back in MethodA. In Stored Procedure2 I have some inner savpoints and rollback. No commit is inside Stored Procedure2 .
    d. Again from MethodA m calling pojo1 where I am getting a new Connection on XA enable datasource1 and executing a diffrent function of Stored Procedure1 of DatabaseSchema1.
    Now problem is:
    I have written some Savepoint and rollback inside Stored Procedure1 and inside Stored Procedure2. But these rollback is working only in inside Stored Procedure1 not in inside Stored Procedure2 in each case.
    In ejb-jar.xml transaction attributes is Required for all methods and transaction type is Container.
    Backend is Oracle 10g and init.xa has already been run on that.
    I have tested this on Oc4J and Websphere 6.0.
    I am using XaDatasource.
    Will be very obliged if any one can give a single hint of the problem as soon as possible.
    Thanks a lot

    Hi Kent;
      You have a few choices (AFAIK) with ASE...
    1)  AutoCommit = TRUE
      - must be before connect to your DB
    2) End your PB transaction first. For example
    String ls_end    =  "END TRANSACTION"
    String ls_begin  =  "BEGIN TRANSACTION"
    EXECUTE IMMEDIATE  ls_end using SQLCA;
    <call your SP>
    EXECUTE IMMEDIATE  ls_begin using SQLCA;
    3) use a 2nd Transaction Object for the SP where its AutoCommit = TRUE
    - or -
    4) In your SP ...
    Commit Transaction
    begin transaction
        insert into mytab (pub_id) values ("9999")
    commit transaction

  • DISTRIBUTED TRANSACTION의 2 PHASE COMMIT 개념 및 절차

    제품 : ORACLE SERVER
    작성날짜 : 2002-05-15
    DISTRIBUTED TRANSACTION의 2 PHASE COMMIT 개념 및 절차
    ====================================================
    Oracle이 분산 트랜잭션 수행을 위해 사용하는 2 phase commit의 자세한 개념
    및 절차를 살펴본다.
    1. 용어와 개념
    Oracle은 분산 트랜잭션을 수행하면서 여기에 포함된 모든 node에 대해서
    session tree를 구성한다. session tree는 분산 트랜잭션에 관여되는 session과
    각 session의 역할을 계층적인 tree형태로 표현한다고 볼 수 있으며,
    DBA_2PC_NEIGHBORS view를 통해 확인 가능하다.
    session tree에 포함되는 각 node들이 수행하는 역할은 2 phase commit 절차의
    기본적인 개념이 되므로, 분산 트랜잭션의 이해를 위해서 정확히 파악할 필요가
    있다. 아래에 각 역할 들의 종류와 의미를 설명하며 [그림 1]을 예로 든다.
    - client
    - database server
    - global coordinator
    - local coordinator
    - commit point site
    insert into seoul_tab...;
    delete from pusan_tab@pusan...;
    Seoul.world inchoen_procedure@incheon...;
    / \ incheon_procedure source
    Pusan.world Inchoen.world ------------------------
    \ delete from incheon_tab...;
    \ update jeju_tab@jeju...;
    Jeju.world
    [그림 1] session tree의 간단한 예제
    (1) client: 다른 node의 database 정보를 이용하면 client가 된다.
    참조되어지는 node는 이때 database server가 된다. seoul.world가
    pusan.world와 incheon.world의 client이고, incheon.world는 jeju.world의
    client가 된다.
    (2) server (database server): 분산 트랜잭션에 포함된 모든 node를 server라
    한다. seoul.world, pusan.world, incheon.world, jeju.world 모두 database
    server이다.
    (3) global coordinator:분산 트랜잭션을 처음 수행시킨 node를 의미한다.
    여기서는 seoul.world가 global coordinator이다.
    (4) local coordinator: 분산 트랜잭션에서 이 node에 관계된 부분의 결과를
    얻으려면 다른 node를 참조해야 하는 경우 이 node를 local coordinator라고
    한다. 이것이 위에서 설명한 global coordinator와는 차이가 있는데 global
    coordinator는 항상 local coordinator이지만, 반대로 local coordinator는
    global coordinator가 아닐 수 있다.
    Incheon.world의 경우 처음 문장을 수행시킨 global coordinator는 아니지만,
    Incheon.world의 Inchoen_procedure내에 jeju.world가 reference되므로
    local coordinator가 된다. seould.world는 global coordinator이면서
    local coordinator가 된다.
    (5) commit point site
    commit point site는 분산 트랜잭션에 관여된 node중 2 phase commit단계에서
    commit이나 rollback을 항상 제일 먼저 하게 된다. 이 node의 local
    transaction부분은 prepared상태를 거치지 않아 in-doubt 상태가 되는 일이
    없고, 그러므로 distributed lock에 의해 조회나 DML시 오류가 발생하는
    없게 된다. 이러한 이유로 제일 중요한 data를 포함하는 중심이 되는 node를
    commit point site로 지정하는 것이 바람직하다.
    commit point site는 각 node의 initialization parameter중
    COMMIT_POINT_STRENGTH 값을 비교하여 제일 큰 값을 가진 node가 지정된다.
    두 node만 관여된 분산 트랜잭션의 경우 commit_point_strength가 지정되어
    있지 않으면, default로 global coordinator가 아닌 node가 commit point
    site가 된다.
    2. 2 Phase Commit (2PC)
    분산 트랜잭션을 commit하는 것은 다음 두 단계를 거치게 된다. 그래서 Oracle의
    분산 트랜잭션은 2 phase commit mechanism을 사용한다고 한다.
    prepare 단계: global coordinator (SQL문장을 처음 수행한 server) 가 commit
    point site를 제외한 나머지 node에게 prepare하도록 요청한다.
    요청을 받은 node는 각 local db에서의 작업에 대해 commit이나
    rollback할 준비를 마치고 다시 global coordinator에게 prepare
    되었음을 알려 주는 단계이다.
    node가 prepare 단계를 지나고 commit을 완료하기 전까지는
    transaction이 in-doubt상태라고 부른다.
    commit단계: 모든 node가 정상적으로 prepare가 되면, 먼저 commit point site가
    commit을 완료하고 이후 다른 node들도 commit을 완료하게 된다.
    이렇게 분산 트랜잭션에서 commit을 수행하기 위해 두 단계를 거치면서 일부
    node만 commit이 되고 일부는 rollback이 되는 불일치 상태를 막을 수 있는데,
    그러기 위한 자세한 단계별 처리 절차를 아래 [표 1]에 17단계로 기술하였다.
    각 단계별로 global coordinator와 commit point site, 그리고 둘 모두에
    해당되지 않는 일반 database server입장으로 나누어 표시하였으며, 만약 어떤
    node가 global coordinator이면서 commit point site라면, 두 part의 일을 모두
    하게 되는 것이다.
    아래 표의 (4) ~ (10)번 단계는 prepare단계의 작업이며, (11) ~ (15)번 단계는 commit단계
    이다. 부가적으로 (16), (17)을 정리 단계로 부르기도 한다.
    단계| Global coordinator | 참여한 db server | Commit point site
    (commit point site도 아니고
    global coordinator도 아닌경우)
    (1) SQL문장 발생 |     |
    (2) SQL문장이 수행되면 session tree가 구성되고 이 정보는
    DBA_2PC_NEIGHBORS를 통해 조회 가능하다.
    변경이 필요한 data는 각 node별로 자기의 local data에 대해서 lock
    (TX,TM)을 걸면서 문장 수행이 진행된다.
    (3) Commit; 문장 발생 |          |
    (4) commit point site를 |          |
    commit_point_strength |          |
    initial parameter를 참조 |          |
    하여 결정하고, |          |
    참여한 모든 node의 SCN중 |          |
    제일 큰 값을 commit SCN으로|           |
    결정하고 이후에 각 node의 |          |
    commit시 이용한다. |          |
    (5) commit point site를 |          |
    제외한 모든 node들에게 |          |
    prepare하도록 요청한다 |          |
    (6) prepare 요청 message받는다 |
    (7) transaction이 이 node의 data를 변경하였는지를 |
    확인하고, 변경 사항이 있고 commit이 가능한 |
    상태이면 다음 단계를 수행하고, 그렇지 않으면 |
    (10)번 단계로 건너뛴다           |
    (8) transaction에 distributed lock을 걸어 fail이 |
    되어도 rollback이 되지 않고 변경 사항에 lock이|
    걸린 채 유지되도록 한다.           |
    distributed lock이 걸려 있는 상태에서는 변경 |
    data를 포함한 block에 포함된 어떤 data도 |
    read/write가 불가능하게 된다 (ora-1591발생) |
    [참조 1]                    |
    (9) transaction에 의해 변경된 내용과 (8)번 단계의 |
    information에 대한 redo log 내용을 각 node의 |
    redo log file에 기록한다. (해당 node의 변경 |
    사항만을 해당 node의 redo log file에 기록) |
    (10) global coordinator에게 다음 세가지 중 하나의 |
    상태를 prepare message대한 응답으로 전달한다.|
    PREPARED:변경된 data가 있고 commit이 가능한 |
    상태               |
    READ-ONLY: 자신의 node에는 data 변경사항이 |
    없고 조회만 관여한 경우 |
    ABORT: 오류 발생으로 인해 commit이 불가능한 |
    경우                     |
    (11) prepare 요청 message에 | |
    대한 응답 중 한 node라도| |
    abort가 있으면: | |
    모든 관여된 node를 | |
    rollback하도록 요청하고 | |
    distributed transaction | |
    을 끝낸다. | |
    prepare요청 message에 | |
    대한 응답이 read-only나 | |
    prepared만 있다면: | |
    commit point site에게 | |
    commit하라고 요청한다. | |
    (12) | |이 node에 관여된 local
    | |transaction 부분만을
    | |commit 한다.
    | |- data변경사항과 commit
    | |정보를 local redo log
    | |file에 기록한다.
    | |- commit SCN은 (4)번단계
                   |           |에서 얻어진, 관여된 node
                   |          |의 SCN중 제일 큰 값을
    | | 이용한다.
                   |     |- (2) 번 단계에서 잡혔던 TX,
    | | TM lock은 해제된다.
    (13) |global coordinator에게
    |commit이 완료되었음을
    |알리는 message를 보낸다.
    (14) commit point site를 제 | |
    외한 다른 node들에게 | |
    commit하라고 요청한다. | |
    (15) commit하면서 (2)번 단계에서 잡은 TX, TM lock|
    과, (8)번 단계에서 잡힌 distributed lock을 |
    release하고, 이러한 commit정보를 redo log |
    file에 기록한다.
    (16) | |DBA_2PC_PENDING,
    | |DBA_2PC_NEIGHBORS등
    | |dictionary 저장된 정보를
    | |지우고 global coordinator
    | |에게 정보를 지웠음을
    | |알려준다
    (17) DBA_2PC_PENDING, DBA_2PC_NEIGHBORS 등 |
    dictionary 저장된 정보를 지우고 정리한다. |
    [참조 2] |
    [표 1] 2 phase commit의 단계별 절차
    [참조 1] distributed lock
    (8)번 단계에서 기술한 distributed lock은 실제 v$lock을 확인하여서는
    나타나지 않는다. v$lock에 lock type이 DX로 나타나는 것은 distributed
    transaction lock으로 이것은 2 phase commit을 위한 것이 아니라
    XA에서 단일 transaction내에서 여러 branch에 대한 control을
    tightly-coupled 형태로 하는 경우에 사용되어 지는 것이므로, 여기서
    언급하는 distributed lock과 혼동되어서는 안된다.
    여기에서 설명한 distributed lock은 실제 type을 가지고 있는 lock이
    아니고 해당 transaction에 대한 local db내의 rollback segment
    header부분에서 transaction상태를 prepared를 나타내는 bit로
         설정함으로써 lock설정을 구현한다.
    그러므로 이 lock이 걸려 있는 동안은 다른 transaction이 해당 분산
    트랜잭션이 변경한 data와 같은 block의 어떠한 data라도 읽거나
    쓰려고 하면, 그 block에 commit되지 않은 transaction이 있다는 것을
    인식하고 before image를 읽기 위해 rollback segment를 찾게 되고,
    그 rollback segment에 prepared상태로 표시되어 있어 before image
    읽는 것을 막기 때문에 오류가 발생하게 된다. 이 오류가 ORA-1591이
    되는 것이다.
    transaction이 prepared상태로 distributed lock이 걸린 상태인지는
    DBA_2PC_PENDING의 status가 PREPARED인지를 확인하는 것만이
    dictionary를 통해 가능한 정보이다.
    [참조 2] DBA_2PC_PENDING의 정보
    DBA_2PC_PENDING view의 정보는 분산 트랜잭션이 비정상 종료 되었을
    때만 정보가 저장되는 것이 아니다. 앞의 [표 1]의 2 phase commit
    단계마다, 수행되는 작업에 대해서 해당 view에 계속해서 정보를
    변경해 가고 앞의 표의 (16), (17) 단계를 완료해야 지워지게 된다.
    분산 트랜잭션이 비정상 종료시 이 view에서 해당 transaction의
    상태가 COLLECTING이나 PREPARED, COMMITTED 상태로 정보가 보여지는
    것은 마지막 정리 단계 수행 전에 transaction이 종료되었기 때문이다.
         non-commit point site의 경우, (10)번 단계에서 distributed lock을
    걸기 전까지는 DBA_2PC_PENDING의 STATE column 값이 COLLECTING으로
    나타나게 되며, (15) 단계 수행전까지는 PREPARED로 나타나고, (17)번
         수행전까지는 COMMITTED로 나타난다.
    commit point site의 경우는, (11)번 수행단계까지는 이 view에 어떠한
    정보도 포함하지 않으며, (12)번 수행 후 (16)번 단계를 수행하기
    전까지는 COMMITTED로 STATE 값을 가지게 된다.

  • Regarding distributed transaction

    may be xi does not support distributed transaction. as 2 phase commit
    really?
    if yeah,and i have the question the following:
    because as far as know,  xi will create seperate transaction for each step.
    and send step will influence the transactional behavior.
    by checking help, i knew
    we can set properties for send step not to start a new transaction.
    can anybody tell me where to set that?
    and then how can we assure transaction integrity.
    if not 2 phase commit protocol, and with what to do it?

    Hi ,
    Please check this blog.
    /people/sap.user72/blog/2005/10/15/jdbc-adapter-execution-mode-chained-or-unchained (JDBC Adapter execution mode Chained or Unchained )
    Ranjeet Singh.

  • Two phase commit and bean managed transactions

    To all the Transaction GURUS!
              Hi guys (-and gals).
              I've been doing J2EE for quite a while, but today was my first at
              XA-Transactions and Bean Managed Transactions.
              Why am I doing this?
              ====================
              Well I have to be able to controll the transactionalbehaviour of my
              bean
              during runtime, since some bean calls would cause a transactional
              overflow due to the stress they would cause to the system, whereas
              smaller bean calls need to run in one transaction.
              -> Therefore I need Bean Managed Transactions
              Since the bean does a call on two Database Connections it has to use a
              XA-Transaction.
              -> Therefore I need XA-Transactions.
              Abstract
              ========
              - I just can't get a User TransAction into the right Status it stays
              in 'STATUS_NO_TRANSACTION' all the time
              - Therefore the SQL Commands can be comitted 'java.sql.SQLException:
              Does not support SQL execution with no global transaction'
              - Therefore I can't do a rollback 'java.lang.IllegalStateException:
              Transaction does not exist'
              - Therefore I wrote this mail.
              I don't want to be a smart-"ass" writing such a detailed and indepth
              mail. I just would like to show that I tried, and would like to have
              some replies from you guys.
              Below are my configurations, code and logfiles.
              Thanx for taking your time and hope that the other people may learn
              something as well.
              cu
              Stefan
              Scenario
              ========
              used Software
              Bea Weblogic (WL) 6.0 SPx (not real sure which SP i have)
              Oracle 8.1.6 using the API-Version 8
              I configured the system as follows:
              (ofcourse I 'xxx'ed out all of the confidential data, sorry guys;-))
              excerpt from:
              config.xml
              <JDBCConnectionPool CapacityIncrement="5"
              DriverName="oracle.jdbc.driver.OracleDriver" InitialCapacity="2"
              LoginDelaySeconds="1" MaxCapacity="5" Name="oraclePool"
              Properties="user=xxx;password=xxx;dll=ocijdbc8;protocol=thin"
              RefreshMinutes="5" Targets="fbsserver" TestConnectionsOnRelease="true"
              TestTableName="languages" URL="jdbc:oracle:thin:@xxx:1521:xxx "/>
              <!-- Since this is our Main Datasource I would not like to use a XA
              Transaction due to performance Issues
              and the TxDataSource:
              -->
              <JDBCTxDataSource EnableTwoPhaseCommit="true"
              JNDIName="finstral.datasource.fbs" Name="finstral Content Datasource"
              PoolName="oraclePool" Targets="fbsserver"/>
              <!-- no comment required -I hope.
              Next comes the "special" Pool
              -->
              <JDBCConnectionPool CapacityIncrement="5"
              DriverName="weblogic.jdbc.oci.xa.XADataSource" InitialCapacity="1"
              LoginDelaySeconds="1" MaxCapacity="2" Name="oracleSecurityPool"
              Properties="user=xxx;password=xxx;server=xxx.xxx.xxx"
              RefreshMinutes="5" Targets="fbsserver" TestConnectionsOnRelease="true"
              TestTableName="Users" SupportsLocalTransaction="true"/>
              <!-- Well since there can only be one none XARessourceManager involved
              in a 2PC
              (keyword: Two Phase Commit) I will have to use a XACapable Driver for
              the other
              Datasource. Due to all the bugs in the oracle.xxx driver. I'll be
              using the jdriver for oci.
              I activated 'SupportsLocalTransaction' hoping it would solve my
              problem - without effect. I just left in there now, since it made
              sense me. Not?
              Again the TxDataSource:
              -->
              <JDBCTxDataSource EnableTwoPhaseCommit="true"
              JNDIName="finstral.datasource.fbssecurity" Name="finstral Security
              Datasource" PoolName="oracleSecurityPool" Targets="fbsserver"/>
              <!-- The System starts right up and can locate the test tables and
              everything. So I think all of this stuff is working here -->
              ejb-jar.xml
              <ejb-jar>
                   <enterprise-beans>
                        <session>
                             <ejb-name>TPCTestBean</ejb-name>
              <home>de.sitewaerts.futuna.common.test.tpcbean.TPCHome</home>
              <remote>de.sitewaerts.futuna.common.test.tpcbean.TPC</remote>
              <ejb-class>de.sitewaerts.futuna.common.test.tpcbean.TPCBean</ejb-class>
                             <session-type>Stateless</session-type>
                             <transaction-type>Bean</transaction-type>
                        </session>
                   </enterprise-beans>
                   <assembly-descriptor/>
              </ejb-jar>
              <!-- Originally I had the assembly-descriptor full of transaction
              requirements. I thought since
              the bean is handling all of the transaction stuff itself, it might get
              confused by the 'container-transaction'
              properties, and deleted them. Do I need them anyway?-->
              weblogic-ejb-jar.xml
              <weblogic-ejb-jar>
                   <weblogic-enterprise-bean>
                        <ejb-name>TPCTestBean</ejb-name>
                        <stateless-session-descriptor/>
                        <jndi-name>finstral/ejb/test_tpc</jndi-name>
                   </weblogic-enterprise-bean>
              </weblogic-ejb-jar>
              <!-- Nothing I have to explain here -->
              BeanCode (from the implementingBeanClass:
              'de.sitewaerts.futuna.common.test.tpcbean.TPCBean')
              public void setupTables() throws RemoteException
              UserTransaction tx = getTransaction();
              //getTransaction calls: 'tx = sCtx.getUserTransaction()' and does
              some errorhandling
              log.info("Die Transaktion vor den Connections: "+tx.toString());
              //Sorry bout the German. You should get the Message though.
              log.info("Der Transaktionsstatus vor den Connections:
              "+transactionStatus(tx));
              Connection conSecurity = getConnection(DATASOURCE_SECURITY, tx);
              //gets a Connection via a DataSourceName from the JNDI tree
              Connection conContent = getConnection(DATASOURCE_CONTENT, tx);
              log.info("Die frische Connection conSecurity: "+conSecurity);
              log.info("Die frische Connection conContent: "+conContent);
              tearDownTable(conSecurity);
              //Does nothing special
              tearDownTable(conContent);
              log.info("Die Transaktion nach dem Teardown: "+tx.toString());
              log.info("Der Transaktionsstatus nach dem Teardown:
              "+transactionStatus(tx));
              Statement stmt = null;
              try
              stmt = conSecurity.createStatement();
              //Well its getting interesting now.....
              log.info("Die Transaktion vor dem createtable: "+tx.toString());
              log.info("Der Transaktionsstatus vor dem createtable:
              "+transactionStatus(tx));
              log.info("Die Connection conSecurity vor dem createtable:
              "+conSecurity);
              log.info("Die Connection conContent vor dem createtable:
              "+conContent);
              stmt.executeUpdate(CREATE_TABLE);
              //above is the row 91 -> throws: 'java.sql.SQLException: Does
              not support SQL execution with no global transaction'
              stmt.close();
              stmt = conContent.createStatement();
              stmt.executeUpdate(CREATE_TABLE);
              stmt.close();
              commitTransaction(tx);
              catch (SQLException sqle)
              log.error("Konnte kein table init machen", sqle);
              rollbackTransaction(tx);
              //The Code for this method is below
              throw new EJBException(sqle);
              finally
              closeConnection(conSecurity);
              closeConnection(conContent);
              protected void rollbackTransaction(UserTransaction tx)
              log.info("Der Transaktionsstatus vor dem Rollback:
              "+transactionStatus(tx));
              log.info("Die Transaktion vor dem Rollback: "+tx.toString());
              try
              tx.rollback();
              //above is row 200 -> throws: 'java.lang.IllegalStateException:
              Transaction does not exist'
              log.info("Der Transaktionsstatus nach dem Rollback:
              "+transactionStatus(tx));
              log.info("Die Transaktion nach dem Rollback: "+tx.toString());
              catch (Exception e)
              log.error("Konnte die Transaktion nicht backrollen.", e);
              throw new EJBException(e);
              Log Excerpt
              ===========
              INFO setupTables() (66) - Die Transaktion vor den Connections:
              [email protected]
              INFO setupTables() (67) - Der Transaktionsstatus vor den Connections:
              STATUS_NO_TRANSACTION
              INFO setupTables() (72) - Die frische Connection conSecurity:
              weblogic.jdbc.rmi.SerialConnection@7c6daa
              INFO setupTables() (73) - Die frische Connection conContent:
              weblogic.jdbc.rmi.SerialConnection@3b425
              INFO setupTables() (78) - Die Transaktion nach dem Teardown:
              [email protected]
              INFO setupTables() (79) - Der Transaktionsstatus nach dem Teardown:
              STATUS_NO_TRANSACTION
              INFO setupTables() (86) - Die Transaktion vor dem createtable:
              [email protected]
              INFO setupTables() (87) - Der Transaktionsstatus vor dem createtable:
              STATUS_NO_TRANSACTION
              INFO setupTables() (88) - Die Connection conSecurity vor dem
              createtable: weblogic.jdbc.rmi.SerialConnection@7c6daa
              INFO setupTables() (89) - Die Connection conContent vor dem
              createtable: weblogic.jdbc.rmi.SerialConnection@3b425
              ERROR setupTables() (101) - Konnte kein table init machen
              java.sql.SQLException: Does not support SQL execution with no global
              transaction
                   at
              weblogic.jdbc.oci.xa.XAConnection.beforeExecute(XAConnection.java:137)
                   at
              weblogic.jdbc.oci.xa.Statement.executeUpdate(Statement.java:112)
                   at weblogic.jdbc.jta.Statement.executeUpdate(Statement.java:185)
                   at
              weblogic.jdbc.rmi.internal.StatementImpl.executeUpdate(StatementImpl.jav
              a:42)
                   at
              weblogic.jdbc.rmi.SerialStatement.executeUpdate(SerialStatement.java:54)
                   at
              de.sitewaerts.futuna.common.test.tpcbean.TPCBean.setupTables(TPCBean.jav
              a:91)
                   at
              de.sitewaerts.futuna.common.test.tpcbean.TPCBeanImpl.setupTables(TPCBean
              Impl.java:130)
                   at
              de.sitewaerts.futuna.common.test.tpcbean.TPCBeanEOImpl.setupTables(TPCBe
              anEOImpl.java:64)
                   at
              de.sitewaerts.futuna.common.test.TwoPhaseCommitUnitTest.setUp(TwoPhaseCo
              mmitUnitTest.java:51)
                   at
              org.apache.commons.cactus.AbstractTestCase.runBareServerTest(AbstractTes
              tCase.java:297)
                   at
              org.apache.commons.cactus.server.ServletTestCaller.callTestMethod(Servle
              tTestCaller.java:148)
                   at
              org.apache.commons.cactus.server.ServletTestCaller.doTest(ServletTestCal
              ler.java:199)
                   at
              org.apache.commons.cactus.server.ServletTestRedirector.doPost(ServletTes
              tRedirector.java:149)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                   at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
              java:213)
                   at
              weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServl
              etContext.java:1265)
                   at
              weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.
              java:1631)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              INFO rollbackTransaction() (196) - Der Transaktionsstatus vor dem
              Rollback: STATUS_NO_TRANSACTION
              INFO rollbackTransaction() (197) - Die Transaktion vor dem Rollback:
              [email protected]
              ERROR rollbackTransaction() (206) - Konnte die Transaktion nicht
              backrollen.
              java.lang.IllegalStateException: Transaction does not exist
                   at
              weblogic.transaction.internal.TransactionManagerImpl.rollback(Transactio
              nManagerImpl.java:228)
                   at
              weblogic.transaction.internal.TransactionManagerImpl.rollback(Transactio
              nManagerImpl.java:222)
                   at
              de.sitewaerts.futuna.common.test.tpcbean.TPCBean.rollbackTransaction(TPC
              Bean.java:200)
                   at
              de.sitewaerts.futuna.common.test.tpcbean.TPCBean.setupTables(TPCBean.jav
              a:102)
                   at
              de.sitewaerts.futuna.common.test.tpcbean.TPCBeanImpl.setupTables(TPCBean
              Impl.java:130)
                   at
              de.sitewaerts.futuna.common.test.tpcbean.TPCBeanEOImpl.setupTables(TPCBe
              anEOImpl.java:64)
                   at
              de.sitewaerts.futuna.common.test.TwoPhaseCommitUnitTest.setUp(TwoPhaseCo
              mmitUnitTest.java:51)
                   at
              org.apache.commons.cactus.AbstractTestCase.runBareServerTest(AbstractTes
              tCase.java:297)
                   at
              org.apache.commons.cactus.server.ServletTestCaller.callTestMethod(Servle
              tTestCaller.java:148)
                   at
              org.apache.commons.cactus.server.ServletTestCaller.doTest(ServletTestCal
              ler.java:199)
                   at
              org.apache.commons.cactus.server.ServletTestRedirector.doPost(ServletTes
              tRedirector.java:149)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                   at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
              java:213)
                   at
              weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServl
              etContext.java:1265)
                   at
              weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.
              java:1631)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              CONCLUSION
              ==========
              I'm going nuts.
              I just don't get it.
              The transaction is the same. I don't change the Connection. I start
              the Transaction at the beginning before I do anything!
              Please guys help me out.
              Thx alot.
              Stefan "it's three o'clock in the morning, my girlfriend left me, and
              my only friend is that stupid linux pinguine" Siprell
              Software-Development
              <<<<<<<<<<<<<<<<<<<<<<<<<<<
              <sitewaerts> GmbH
              Hebelstraße 15
              D-76131 Karlsruhe
              Tel: +49 (721) 920 918 22
              Fax: +49 (721) 920 918 29
              http://www.sitewaerts.de
              >>>>>>>>>>>>>>>>>>>>>>>>>>>
              

    Hi Priscilla
              (did you ever see the movie ? :-))
              Well I moved away from the idea of using bean managed transaction. I'll
              be using Container Managed Transactions. To modify the
              transactionalbehaviour I'll write proxymethods which have certain
              different containermanaged transaction properties, but which all call
              the same private methods.
              But it works! Here is my experience:
              - I was doing a DDL statement: I was trying to create new Tables, which
              is a definite "no-go"
              - pay careful attention to:
              http://edocs.bea.com/wls/docs60/jta/trxejb.html#1051405
                        and
              http://edocs.bea.com/wls/docs60/jta/trxejb.html#1051741
              and use these Settings for the Pool, don't ask me why, but it took me
              hours to find it out by myself:
                   <JDBCConnectionPool CapacityIncrement="5"
              DriverName="weblogic.jdbc.oci.xa.XADataSource" InitialCapacity="1"
              LoginDelaySeconds="1" MaxCapacity="2" Name="oracleSecurityPool"
              Properties="user=xxx; password=xxx; server=xxx.xxx.xxx"
              RefreshMinutes="5" Targets="fbsserver" TestConnectionsOnRelease="true"
              TestTableName="Users" SupportsLocalTransaction="true"/>
              where as the server (shown as: xxx.xxx.xxx) is the TNS Name of the
              Oracle Driver.
              It works great.
              Another thing you guys might want to do is write a simple StatelessSB
              which does JDBC calls and two different database Connections.
              Then write a UnitTest which calls this bean a couple hundred times (with
              the same transaction). Have one test do clean writes, and another which
              causes some SQL-Exception (too long Data Columns, or likewise).
              Always count the entries and see if everything worked out. We're using
              this SetupConstruction to test new combinations of AS(sorry Priscilla) /
              Database / Db-Drivers to have a "standard test".
              I know my two cents were uncalled for, but it might save you some
              time.....
              thanx for your help
              Stefan
              -----Ursprüngliche Nachricht-----
              Von: Priscilla Fung [mailto:[email protected]]
              Bereitgestellt: Donnerstag, 2. August 2001 21:42
              Bereitgestellt in: transaction
              Unterhaltung: Two phase commit and bean managed transactions
              Betreff: Re: Two phase commit and bean managed transactions
              Hi Stefan,
              Looks like you have not actually begun a transaction by calling
              UserTransaction.begin(),
              so your setupTables method is really executing with no transaction
              context.
              Priscilla
              Stefan Siprell <[email protected]> wrote:
              >To all the Transaction GURUS!
              >
              >Hi guys (-and gals).
              >I've been doing J2EE for quite a while, but today was my first at
              >XA-Transactions and Bean Managed Transactions.
              >
              >Why am I doing this?
              >====================
              >Well I have to be able to controll the transactionalbehaviour of my
              >bean
              >during runtime, since some bean calls would cause a transactional
              >overflow due to the stress they would cause to the system, whereas
              >smaller bean calls need to run in one transaction.
              >-> Therefore I need Bean Managed Transactions
              >Since the bean does a call on two Database Connections it has to use
              >a
              >XA-Transaction.
              >-> Therefore I need XA-Transactions.
              >
              >Abstract
              >========
              >- I just can't get a User TransAction into the right Status it stays
              >in 'STATUS_NO_TRANSACTION' all the time
              >- Therefore the SQL Commands can be comitted 'java.sql.SQLException:
              >Does not support SQL execution with no global transaction'
              >- Therefore I can't do a rollback 'java.lang.IllegalStateException:
              >Transaction does not exist'
              >- Therefore I wrote this mail.
              >
              >I don't want to be a smart-"ass" writing such a detailed and indepth
              >mail. I just would like to show that I tried, and would like to have
              >some replies from you guys.
              >
              >Below are my configurations, code and logfiles.
              >
              >Thanx for taking your time and hope that the other people may learn
              >something as well.
              >
              >cu
              >
              >Stefan
              >
              >
              >Scenario
              >========
              >
              >used Software
              >-------------
              >Bea Weblogic (WL) 6.0 SPx (not real sure which SP i have)
              >Oracle 8.1.6 using the API-Version 8
              >
              >
              >I configured the system as follows:
              >(ofcourse I 'xxx'ed out all of the confidential data, sorry guys;-))
              >excerpt from:
              >
              >config.xml
              >----------
              ><JDBCConnectionPool CapacityIncrement="5"
              >DriverName="oracle.jdbc.driver.OracleDriver" InitialCapacity="2"
              >LoginDelaySeconds="1" MaxCapacity="5" Name="oraclePool"
              >Properties="user=xxx;password=xxx;dll=ocijdbc8;protocol=thin"
              >RefreshMinutes="5" Targets="fbsserver" TestConnectionsOnRelease="true"
              >TestTableName="languages" URL="jdbc:oracle:thin:@xxx:1521:xxx "/>
              >
              ><!-- Since this is our Main Datasource I would not like to use a XA
              >Transaction due to performance Issues
              >and the TxDataSource:
              >-->
              >
              ><JDBCTxDataSource EnableTwoPhaseCommit="true"
              >JNDIName="finstral.datasource.fbs" Name="finstral Content Datasource"
              >PoolName="oraclePool" Targets="fbsserver"/>
              >
              ><!-- no comment required -I hope.
              >Next comes the "special" Pool
              >-->
              >
              ><JDBCConnectionPool CapacityIncrement="5"
              >DriverName="weblogic.jdbc.oci.xa.XADataSource" InitialCapacity="1"
              >LoginDelaySeconds="1" MaxCapacity="2" Name="oracleSecurityPool"
              >Properties="user=xxx;password=xxx;server=xxx.xxx.xxx"
              >RefreshMinutes="5" Targets="fbsserver" TestConnectionsOnRelease="true"
              >TestTableName="Users" SupportsLocalTransaction="true"/>
              >
              ><!-- Well since there can only be one none XARessourceManager involved
              >in a 2PC
              >(keyword: Two Phase Commit) I will have to use a XACapable Driver for
              >the other
              >Datasource. Due to all the bugs in the oracle.xxx driver. I'll be
              >using the jdriver for oci.
              >I activated 'SupportsLocalTransaction' hoping it would solve my
              >problem - without effect. I just left in there now, since it made
              >sense me. Not?
              >Again the TxDataSource:
              >-->
              >
              ><JDBCTxDataSource EnableTwoPhaseCommit="true"
              >JNDIName="finstral.datasource.fbssecurity" Name="finstral Security
              >Datasource" PoolName="oracleSecurityPool" Targets="fbsserver"/>
              >
              ><!-- The System starts right up and can locate the test tables and
              >everything. So I think all of this stuff is working here -->
              >
              >
              >
              >ejb-jar.xml
              >-----------
              ><ejb-jar>
              >     <enterprise-beans>
              >          <session>
              >               <ejb-name>TPCTestBean</ejb-name>
              >     
              ><home>de.sitewaerts.futuna.common.test.tpcbean.TPCHome</home>
              >     
              ><remote>de.sitewaerts.futuna.common.test.tpcbean.TPC</remote>
              >     
              ><ejb-class>de.sitewaerts.futuna.common.test.tpcbean.TPCBean</ejb-class>
              >               <session-type>Stateless</session-type>
              >               <transaction-type>Bean</transaction-type>
              >          </session>
              >     </enterprise-beans>
              >     <assembly-descriptor/>
              ></ejb-jar>
              >
              ><!-- Originally I had the assembly-descriptor full of transaction
              >requirements. I thought since
              >the bean is handling all of the transaction stuff itself, it might get
              >confused by the 'container-transaction'
              >properties, and deleted them. Do I need them anyway?-->
              >
              >weblogic-ejb-jar.xml
              >--------------------
              ><weblogic-ejb-jar>
              >     <weblogic-enterprise-bean>
              >          <ejb-name>TPCTestBean</ejb-name>
              >          <stateless-session-descriptor/>
              >          <jndi-name>finstral/ejb/test_tpc</jndi-name>
              >     </weblogic-enterprise-bean>
              ></weblogic-ejb-jar>
              >
              ><!-- Nothing I have to explain here -->
              >
              >BeanCode (from the implementingBeanClass:
              >'de.sitewaerts.futuna.common.test.tpcbean.TPCBean')
              >-----------------------------------------------------------------------
              >---------------------
              >
              > public void setupTables() throws RemoteException
              > {
              > UserTransaction tx = getTransaction();
              > //getTransaction calls: 'tx = sCtx.getUserTransaction()' and does
              >some errorhandling
              >
              > log.info("Die Transaktion vor den Connections: "+tx.toString());
              > //Sorry bout the German. You should get the Message though.
              > log.info("Der Transaktionsstatus vor den Connections:
              >"+transactionStatus(tx));
              >
              > Connection conSecurity = getConnection(DATASOURCE_SECURITY, tx);
              > //gets a Connection via a DataSourceName from the JNDI tree
              > Connection conContent = getConnection(DATASOURCE_CONTENT, tx);
              >
              > log.info("Die frische Connection conSecurity: "+conSecurity);
              > log.info("Die frische Connection conContent: "+conContent);
              >
              > tearDownTable(conSecurity);
              > //Does nothing special
              > tearDownTable(conContent);
              >
              > log.info("Die Transaktion nach dem Teardown: "+tx.toString());
              > log.info("Der Transaktionsstatus nach dem Teardown:
              >"+transactionStatus(tx));
              >
              > Statement stmt = null;
              > try
              > {
              > stmt = conSecurity.createStatement();
              > //Well its getting interesting now.....
              >
              > log.info("Die Transaktion vor dem createtable: "+tx.toString());
              > log.info("Der Transaktionsstatus vor dem createtable:
              >"+transactionStatus(tx));
              > log.info("Die Connection conSecurity vor dem createtable:
              >"+conSecurity);
              > log.info("Die Connection conContent vor dem createtable:
              >"+conContent);
              >
              > stmt.executeUpdate(CREATE_TABLE);
              > //above is the row 91 -> throws: 'java.sql.SQLException: Does
              >not support SQL execution with no global transaction'
              >
              > stmt.close();
              >
              > stmt = conContent.createStatement();
              > stmt.executeUpdate(CREATE_TABLE);
              > stmt.close();
              > commitTransaction(tx);
              > }
              > catch (SQLException sqle)
              > {
              > log.error("Konnte kein table init machen", sqle);
              > rollbackTransaction(tx);
              > //The Code for this method is below
              > throw new EJBException(sqle);
              > }
              > finally
              > {
              > closeConnection(conSecurity);
              > closeConnection(conContent);
              > }
              > }
              >
              > protected void rollbackTransaction(UserTransaction tx)
              > {
              > log.info("Der Transaktionsstatus vor dem Rollback:
              >"+transactionStatus(tx));
              > log.info("Die Transaktion vor dem Rollback: "+tx.toString());
              > try
              > {
              > tx.rollback();
              > //above is row 200 -> throws: 'java.lang.IllegalStateException:
              >Transaction does not exist'
              > log.info("Der Transaktionsstatus nach dem Rollback:
              >"+transactionStatus(tx));
              > log.info("Die Transaktion nach dem Rollback: "+tx.toString());
              > }
              > catch (Exception e)
              > {
              > log.error("Konnte die Transaktion nicht backrollen.", e);
              > throw new EJBException(e);
              > }
              > }
              >
              >Log Excerpt
              >===========
              >INFO setupTables() (66) - Die Transaktion vor den Connections:
              >[email protected]
              >INFO setupTables() (67) - Der Transaktionsstatus vor den Connections:
              >STATUS_NO_TRANSACTION
              >INFO setupTables() (72) - Die frische Connection conSecurity:
              >weblogic.jdbc.rmi.SerialConnection@7c6daa
              >INFO setupTables() (73) - Die frische Connection conContent:
              >weblogic.jdbc.rmi.SerialConnection@3b425
              >INFO setupTables() (78) - Die Transaktion nach dem Teardown:
              >[email protected]
              >INFO setupTables() (79) - Der Transaktionsstatus nach dem Teardown:
              >STATUS_NO_TRANSACTION
              >INFO setupTables() (86) - Die Transaktion vor dem createtable:
              >[email protected]
              >INFO setupTables() (87) - Der Transaktionsstatus vor dem createtable:
              >STATUS_NO_TRANSACTION
              >INFO setupTables() (88) - Die Connection conSecurity vor dem
              >createtable: weblogic.jdbc.rmi.SerialConnection@7c6daa
              >INFO setupTables() (89) - Die Connection conContent vor dem
              >createtable: weblogic.jdbc.rmi.SerialConnection@3b425
              >ERROR setupTables() (101) - Konnte kein table init machen
              >java.sql.SQLException: Does not support SQL execution with no global
              >transaction
              >     at
              >weblogic.jdbc.oci.xa.XAConnection.beforeExecute(XAConnection.java:137)
              >     at
              >weblogic.jdbc.oci.xa.Statement.executeUpdate(Statement.java:112)
              >     at weblogic.jdbc.jta.Statement.executeUpdate(Statement.java:185)
              >     at
              >weblogic.jdbc.rmi.internal.StatementImpl.executeUpdate(StatementImpl.ja
              v
              >a:42)
              >     at
              >weblogic.jdbc.rmi.SerialStatement.executeUpdate(SerialStatement.java:54
              >     at
              >de.sitewaerts.futuna.common.test.tpcbean.TPCBean.setupTables(TPCBean.ja
              v
              >a:91)
              >     at
              >de.sitewaerts.futuna.common.test.tpcbean.TPCBeanImpl.setupTables(TPCBea
              n
              >Impl.java:130)
              >     at
              >de.sitewaerts.futuna.common.test.tpcbean.TPCBeanEOImpl.setupTables(TPCB
              e
              >anEOImpl.java:64)
              >     at
              >de.sitewaerts.futuna.common.test.TwoPhaseCommitUnitTest.setUp(TwoPhaseC
              o
              >mmitUnitTest.java:51)
              >     at
              >org.apache.commons.cactus.AbstractTestCase.runBareServerTest(AbstractTe
              s
              >tCase.java:297)
              >     at
              >org.apache.commons.cactus.server.ServletTestCaller.callTestMethod(Servl
              e
              >tTestCaller.java:148)
              >     at
              >org.apache.commons.cactus.server.ServletTestCaller.doTest(ServletTestCa
              l
              >ler.java:199)
              >     at
              >org.apache.commons.cactus.server.ServletTestRedirector.doPost(ServletTe
              s
              >tRedirector.java:149)
              >     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
              >     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              >     at
              >weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl
              >java:213)
              >     at
              >weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServ
              l
              >etContext.java:1265)
              >     at
              >weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl
              >java:1631)
              >     at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              >     at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >INFO rollbackTransaction() (196) - Der Transaktionsstatus vor dem
              >Rollback: STATUS_NO_TRANSACTION
              >INFO rollbackTransaction() (197) - Die Transaktion vor dem Rollback:
              >[email protected]
              >ERROR rollbackTransaction() (206) - Konnte die Transaktion nicht
              >backrollen.
              >java.lang.IllegalStateException: Transaction does not exist
              >     at
              >weblogic.transaction.internal.TransactionManagerImpl.rollback(Transacti
              o
              >nManagerImpl.java:228)
              >     at
              >weblogic.transaction.internal.TransactionManagerImpl.rollback(Transacti
              o
              >nManagerImpl.java:222)
              >     at
              >de.sitewaerts.futuna.common.test.tpcbean.TPCBean.rollbackTransaction(TP
              C
              >Bean.java:200)
              >     at
              >de.sitewaerts.futuna.common.test.tpcbean.TPCBean.setupTables(TPCBean.ja
              v
              >a:102)
              >     at
              >de.sitewaerts.futuna.common.test.tpcbean.TPCBeanImpl.setupTables(TPCBea
              n
              >Impl.java:130)
              >     at
              >de.sitewaerts.futuna.common.test.tpcbean.TPCBeanEOImpl.setupTables(TPCB
              e
              >anEOImpl.java:64)
              >     at
              >de.sitewaerts.futuna.common.test.TwoPhaseCommitUnitTest.setUp(TwoPhaseC
              o
              >mmitUnitTest.java:51)
              >     at
              >org.apache.commons.cactus.AbstractTestCase.runBareServerTest(AbstractTe
              s
              >tCase.java:297)
              >     at
              >org.apache.commons.cactus.server.ServletTestCaller.callTestMethod(Servl
              e
              >tTestCaller.java:148)
              >     at
              >org.apache.commons.cactus.server.ServletTestCaller.doTest(ServletTestCa
              l
              >ler.java:199)
              >     at
              >org.apache.commons.cactus.server.ServletTestRedirector.doPost(ServletTe
              s
              >tRedirector.java:149)
              >     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
              >     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              >     at
              >weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl
              >java:213)
              >     at
              >weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServ
              l
              >etContext.java:1265)
              >     at
              >weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl
              >java:1631)
              >     at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              >     at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >
              >
              >CONCLUSION
              >==========
              >I'm going nuts.
              >I just don't get it.
              >The transaction is the same. I don't change the Connection. I start
              >the Transaction at the beginning before I do anything!
              >Please guys help me out.
              >Thx alot.
              >
              >Stefan "it's three o'clock in the morning, my girlfriend left me, and
              >my only friend is that stupid linux pinguine" Siprell
              >Software-Development
              ><<<<<<<<<<<<<<<<<<<<<<<<<<<
              ><sitewaerts> GmbH
              >Hebelstraße 15
              >D-76131 Karlsruhe
              >
              >Tel: +49 (721) 920 918 22
              >Fax: +49 (721) 920 918 29
              >http://www.sitewaerts.de
              >>>>>>>>>>>>>>>>>>>>>>>>>>>>
              >
              >
              >
              

Maybe you are looking for

  • Internal table in se24

    Hi , How to declar the 'TYPE TABLE OF' in se24. Please spend some time actually looking for the answer. There is plenty of info on this available if you actually search. Thread locked. Edited by: Neil Gardiner on Jul 6, 2011 2:57 PM

  • Creation of Material using BDC Session method & global class

    Hi Creation of Material using BDC Session method & global class by using oops. can anyone plz help me out

  • How to use ODI Variables in Jython

    Hi, im doing a dynamic interfaz .. so i make a connection to bd. When i try to do it .. i got an error... How can i access to the odi variables from odi.. this is my code .. <% import java.sql.*; import java.io.*; BufferedWriter bw = new BufferedWrit

  • Parsing Date and converting it toString()

    Hi, When I parse my date to a specific timezone, why does it not display that same timezone when I convert it to a string? Instead it seems to be using my system's current timezone, and I don't want that. This is how I'm doing it... SimpleDateFormat

  • Epson Print CD v2.00.00A crashes on launch

    I have installed Epson Print CD on two G5s. One works fine so it is not the program. The other G5 begins to open the app but I get this message. "The application Epson Print CD quit unexpectedly. Mac OS X and other applications are not affected. Clic