0 Replies Latest reply on Sep 28, 2001 6:49 AM by maouche

    Commit/Rollback problems with UserTransaction

    maouche

      I have a problem when I try to excute the this Client code. Can you tell me Why Please .

      public class MyClientPur {
      public static void main(String [] args){
      UserTransaction ut =null;

      try {
      Context ctx = new InitialContext();
      ut = (UserTransaction) ctx.lookup("UserTransaction");
      ut.setTransactionTimeout(100);

      Object objectRef = ctx.lookup("mybo/MyPur");
      MyPurHome home = (MyPurHome) javax.rmi.PortableRemoteObject.narrow (objectRef, MyPurHome.class );

      try{
      ut.begin();
      MyPur mybo= home.findByNom("toto");
      mybo.setprenom("Valid60");
      mybo.setage(new Long(60));

      MyPur mybo2 = home.create();
      mybo2.setnom("Betha21");
      mybo2.setprenom("OKKK60");
      ut.commit(); //rollback();

      }
      catch (Exception ex){
      System.out.println("find/create failed."+ex.toString());
      ex.printStackTrace();

      }
      ...
      }


      This code has a good behavior without UserTransaction demarcation.

      I have this Error message

      [java] javax.transaction.RollbackException: Unable to commit, tx=XidImpl [FormatId=257, GlobalId=nx0032.nextenso.alcatel.fr//0, BranchQual=] status=STATUS_ROLLEDBACK
      [java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
      [java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
      [java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
      [java] at org.jboss.tm.usertx.server.UserTransactionSessionImpl_Stub.commit(Unknown Source)
      [java] at org.jboss.tm.usertx.client.ClientUserTransaction.commit(ClientUserTransaction.java:139)
      [java] at mybo.MyClientPur.main(MyClientPur.java:101)



      - The transaction attribute of my Entity Bean is Required for all methods.
      - At the beginning of a method , I get the connection datasource.getConnection(). And I close it at the end in finally { ... con.close(); ...}


      my jboss.jcml is configured with ORACLE driver

      jdbc/NextensoHTS
      org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
      jdbc:oracle:oci8:@(DESCRIPTION=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=nx0032)(Port=1521))(CONNECT_DATA=(SID=HTS)))
      1200000
      hometopuser
      10
      hometoppass
      false
      false
      false
      false
      120000
      1800000
      false
      false
      1.0
      0



      In the server.log, I have :

      ....

      [jdbc/NextensoHTS] Resource 'org.jboss.pool.jdbc.xa.wrapper.XAResourceImpl@2803d5' enlisted for 'org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@664686'.
      [jdbc/NextensoHTS] Pool jdbc/NextensoHTS [1/2/10] gave out pooled object: org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@664686
      [MyPurBean] Activated bean MyPurBean with id = 10
      [jdbc/NextensoHTS] No transaction right now.
      [jdbc/NextensoHTS] Pool jdbc/NextensoHTS [2/2/10] gave out pooled object: org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@2dae91
      [jdbc/NextensoHTS] Pool jdbc/NextensoHTS [1/2/10] returned object org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@2dae91 to the pool.
      [EntitySynchronizationInterceptor] Store failed
      javax.ejb.EJBException: Echec Update Object
      at mybo.MyPurBean.ejbStore(MyPurBean.java:115)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenceManager.java:347)
      at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:252)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor$InstanceSynchronization.beforeCompletion(EntitySynchronizationInterceptor.java:400)
      at org.jboss.tm.TxCapsule.doBeforeCompletion(TxCapsule.java:1210)
      at org.jboss.tm.TxCapsule.commit(TxCapsule.java:304)
      at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:76)
      at org.jboss.tm.usertx.server.UserTransactionSessionImpl.commit(UserTransactionSessionImpl.java:163)
      at java.lang.reflect.Method.invoke(Native Method)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
      at sun.rmi.transport.Transport$1.run(Transport.java:142)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643)
      at java.lang.Thread.run(Thread.java:484)
      [jdbc/NextensoHTS] Pool jdbc/NextensoHTS [0/2/10] returned object org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@664686 to the pool.


      The transaction attribute of my Entity Bean is Required for all methods.

      At the beginning of a method , I get the connection datasource.getConnection()

      And I close it at the end in finally { ... con.close(); ...}