Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Q: starting transactions from JSP

0 views
Skip to first unread message

poseidon

unread,
Oct 31, 2001, 4:10:33 AM10/31/01
to
Hi, All

I have a JSP file and I want to start transaction from it.

According to O'Reilly's "Enterprise JavaBean", it seems to be possible to
start transaction by J2EE clients but when I tried it on Borland JBuilder5
Enterprise, I could not control transactions well. What I did was:


In a JSP, I have something like this to start a transaction

<%
Context jidiCntx = new InitialContext();
UserTransaction tran = (UserTransaction)
jidiCntx.lookup("java:comp/UserTransaction");
tran.begin();
%>

then

<%
call cmp entity EJBs through JavaBeans (a)
call a session EJB through JavaBean. the session EJB, in turn, calls
other cmp entity EJBs. (b)
call the same session EJB. this time the session EJB updates database by
itself (c)
%>

<% tran.commit(); %>

this locks up database tables for a while or forever after the commit. If it
comes back, only (b) and (c) committed.

When I don't start transaction in a JSP but I start transaction and commit
in the stateful (must be stateful otherwise I cannot leave transaction open)
session EJB instead, everything seems to work. In that case, of course, (a)
and (b)/(c) are done in different transactions. If the session EJB
rollbacks, only (b) and (c) are rollbacked. (a) is committed anyway unless
it rollbacks itself.

I use Borland JBuilder 5 Enterprise, Borland App Server, MS SQL2000 and
Merant JDBC driver.

I appreciate any thought.


Thank you.

poseidon

0 new messages