--- Dasarath Weeratunge <[EMAIL PROTECTED]>写道:
> Quoting Jack Wang <[EMAIL PROTECTED]>:
>
> if things are working the way they should, when you call getTransaction on
> the
> TM object that you get from the Bridge from within the service impl of your
> ws
> it should return a non NULL tx object unless you invoked your ws without a
> coordination ctx. Please look at test-suite1. It shows how to do this.
>
> --dasarath
I have got tm from the Bridge within the service impl of my ws, and also
called the ws by
kandula (between wstm.begin() and wstm.rollback()). But the tx in the impl is
still null.The
situation is illustrated in the previous mail as following. I wonder if I have
missed sth. The
code is as follow.
====client======
TransactionManagerImpl wstm = TransactionManagerImpl.getInstance();
wstm.begin();
po.MyService binding = new MyServiceServiceLocator().getMyService();
((MyServiceSoapBindingStub)binding).setMaintainSession(true);
String result = binding.getString();
wstm.rollback();
================
and
====server======
public java.lang.String getString() in ...Impl {
TransactionManager tm = Bridge.getInstance().getTM();
javax.transaction.Transaction tx = tm.getTransaction();
System.out.println("[MyService] =============== ");
System.out.println("[MyService] tx = " + tx + " is NULL ");
System.out.println("[MyService] =============== ");
Context ctx = new InitialContext();
XADataSource xaDs = (XADataSource)ctx.lookup("java:comp/env/jdbc/myXADB");
((StandardXADataSource)xaDs).setTransactionManager(tm);
XAConnection xCon = xaDs.getXAConnection("root", "password");
java.sql.Connection conn = xCon.getConnection();
XAResource xRes = xCon.getXAResource();
// ++++++++++++++++++++++++
// tx.enlistResource(xRes); <== Can not enlist xRes
// ++++++++++++++++++++++++
PreparedStatement pstmt = conn.prepareStatement("...");
pstmt.executeUpdate();
return "<MyService is ok>";
}
================
What's wrong ?
In addition, Should I write rollback() method in Impl of the ws which will
be called by
kandula client to control the ws's rollback if exception occurs in the client,
as the example
TestSuite1 ? Or should you give me some steps if you have time ?
Thanks.
Wangjun
>
> > --- Dasarath Weeratunge <[EMAIL PROTECTED]>写道:
> > > keep on forgetting to send replies to the list...
> > >
> > > ----- Forwarded message from Dasarath Weeratunge <[EMAIL PROTECTED]>
> > -----
> > > Date: Sun, 12 Feb 2006 14:11:35 -0500
> > > From: Dasarath Weeratunge <[EMAIL PROTECTED]>
> > > Reply-To: Dasarath Weeratunge <[EMAIL PROTECTED]>
> > > Subject: Re: MySQL's XA problem
> > > To: Jack Wang <[EMAIL PROTECTED]>
> > >
> > > Quoting Jack Wang <[EMAIL PROTECTED]>:
> > >
> > > >
> > > > The java code (JOTM example):
> > > > ========================================================
> > > > UserTransaction ut = null;
> > > > try{
> > > > Context ctx = new InitialContext();
> > > > MysqlXADataSource xaDs =
> > > > (MysqlXADataSource)ctx.lookup("java:comp/env/jdbc/myXADB");
> > > > ut = (UserTransaction)ctx.lookup("java:comp/env/UserTransaction");
> > >
> > > How did u obtain this UserTransaction Object? It should come from the
> > Geronimo
> > > TM object instantiated by Bridge.
> > >
> >
> > Hi, Dasarath. Thanks you. I come back.
> >
> > This UserTransaction Object is obtained from Tomcat 5.5 in which I have
> > configured
> > UserTransaction with JOTM . In the non ws environment, the ut controls the
> > db
> > operation correctly
> > with ut.rollback() or ut.commit(), i.e. Now I can do XA operation in a jsp
> > or
> > a java bean.
> >
> > Current situation is that I can get the not null local tm, but the local
> > tx is null from this
> > tm regardless I use JOTM's tm or Bridge's tm. So I can not enlist the
> > XAResource to the tx. So in
> > the ws environment, I can call the ws by kandula, but the wstm.rollback()
> > did
> > not effect on the ws
> > side's database.
> >
> > So how can I get the correct tx to enlist the XAResource ?
> >
> > p.s. After I get the XADataSource, I have set the tm to xaDs. If I
> > commit
> > the ut, the database
> > will be effected though I use wstm.rollback() in the client side.
> > -----------------------------------------------
> > // Get tx
> > TransactionManager tm = jotm.getTransactionManager();
> > //or
> > TransactionManager tm = o.a.k.g.Bridge.getInstance().getTM();
> > javax.transaction.Transaction tx = tm.getTransaction(); <== NULL, Ooops
> >
> > // Get xaRes
> > XADataSource xaDs = (XADataSource)ctx.lookup("java:comp/env/jdbc/myXADB");
> > // tm <--> xaDs
> > ((StandardXADataSource)xaDs).setTransactionManager(tm);
> > XAConnection xCon = xaDs.getXAConnection("root", "password");
> > XAResource xRes = xCon.getXAResource();
> >
> > // Here should add tx.enlistResource(xRes), but tx is null
> >
> > // Following is the db operation ...
> > java.sql.Connection conn = xCon.getConnection();
> > -----------------------------------------------
> >
> > >
> > >
> > > Here we go once again. Please don't commit the tx in your code. The tx
> > > will
> > be
> > > started and commited when you terminate your distributed (ws-at) tx using
> > wa-at
> > > Completion protocol. If you want to rollback your tx, you may do so
> > however.
> > > Even then it is better to mark the tx as "RollbackOnly".
> > >
> > > I will give u some steps later on.
> > >
> > > --dasarath
> >
__________________________________________________
赶快注册雅虎超大容量免费邮箱?
http://cn.mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]