Hello all,
I am new to the EJBMailList group, but recently we have been benefited a lot
from contributions that you all made to this group. Now I have a specific
requirement from EJB Architecture in our application (may be a Unique one &
a LONG explanation).
Our Requirement:
To execute one database transaction in EJB (TX1), one in existing Clibrary
(TX2) (using Embedded SQL) and last one in EJB (TX3) may be using same or
different EntityBeans from one Session Bean. And all these TX1, TX2 and
TX3 should be in ATOMIC i.e. even if one transaction fails either in EJB or
Clibrary all the Tranasactions should be rolled back.
For example: consider one EntityBean called "EB_PFAccount" which is mapped
to a table with "accounNumber" (as Primary Key in EntityBean) and "balance"
as column names. Consider one SessionBean called SB_TxSession, which
access the EB_PFAccount. Using this SessionBean, TX1, TX2 and TX3
transactions to be carried out. The TX2 transaction is in Clibrary using
JNI, other two TX1 and TX3 in Session Bean.
What I have tried:
But as a first step, I have tried to do database transactions in Clibrary
on one EntityBean called EB_PFAccount , using JNI to call the Clibrary
(having Embedded SQL to do transaction) . This bean has accno as
PrimaryKey and balance as additional attribute mapped to the table column.
Used SB_TxSessionBean to do transactions on EB_PFAccount. In Clibrary I
have got connection to SQLServer, executed SELECT and UPDATE on table
that is mapped to EB_PFAccount) and closing the connection.
All these are carried out only on Weblogic EJBServer 4.0.3 on NT4.0, (on
other Vendor server it may behave differently). Here MS SQLServer 7.0 is
used as Database Server.
I have tried the above mentioned application, with all the TX_ attributes
(except TX_SUPPORT, as this is not supported in the Weblogic Server) on the
SessionBean and EntityBean, with & without reEntrant allowed , with
dbIsShared TRUE & FALSE , with & without ContainerManaged etc. The
following are the results:
A) On the DataBase table:
The database table is getting updated as required.
But, when I use getBalance () on EntityBean to get balance value it is
giving following error:
B) On the server side:
TxCoordinator LOG: java.sql.SQLException: The coordinator has rolled back
the transaction.
No further JDBC access is allowed within this transaction.
at weblogic.jdbc.jts.Connection.checkIfRolledBack(Compiled Code)
���..
java.sql.SQLException: Cannot turn off auto-commit. Cannot query
@@trancount with connection in this state.
C) On the Client side :
It is throwing "RemoteException" if I try to get the balance using EB's
getBalance() method . Again if I try from Client to do same Transaction ,
it is throwing "FinderException" when findByPrimaryKey() is used on this
EntityBean . Now even if I try to access EB_PFAccount from another
client it gives "FinderException" , as if the EJBServer is completely
locking this EntityBean.
The above Exception or errors are not seen if normal Java client is used and
call Clibrary Transaction. As per my knowledge the container may be
creating a Transaction context in the SessionBean and attaching to the
thread which is doing the Transaction. And this Transaction Context is the
one that is locking the EntityBean (I may be wrong here, as this may similar
to OTS !). The above exceptions are coming even if I use TX_NOT_SUPPORTED
for both Entity and Session Bean, this is confusing !!.
My doubts / Queries:
1. How to achieve required Clibrary transaction without this exception?
2. What are best combinations of the attributes in the Deployment Descriptor
file to be used ?
3. As lot so work is done by the Container it trace out the problem, any
suggestions on how to track the problem ?
4. Is there any Design pattern present in EJB for this kind of Requirement
?
5. Will this behave differently on Oracle or Informix ?
6. How / When is " turn off auto-commit " is called , as this is called b
y Container from the generated files it is difficult find out ? . Is there
any way to modify this in the deployment descriptor as per our requirement ?
7. What is "TxCoordinator" which is coordinating the transaction
8. Weblogic Container seems to maintain variable "trancount" to for counting
Transactions, and if the trancount is greater than zero it is throwing the
SQL Exception, with connection in a particular state, how to control this ?
9. Or the only solution is to wrap the required Clibrary in CORBA object and
use them from EJB?
If I have confused anybody please do ask me on [EMAIL PROTECTED] , this
will help me. Any suggestions from experienced EJB experts will help us for
trying out this requirement on EJB Architecture.
Thank you,
Regards,
G Srinivas
==========================
L&T Information Technology Ltd.
'Subhalaxmi', 1205/1-3-4,
Off Shirole Road,
ShivajiNagar,
Pune - 411 005 ( INDIA )
Phone : 91 20 5530813 - 18
EMail : [EMAIL PROTECTED]
Web : www.ltitl.com
==========================
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".