Hello everybody,
we are having trouble with the exception-handling jonas does for ejbStore()
of entity beans. I posted this problem some time ago but so far there was no
solution and we can't find a way to work around.
It seems that jonas does not forward exceptions to the client program which
result from performing ejbStore(). This applies both to bean-managed
persistence and container-managed persistence. The problem does **not**
occur in the ejCreate() or ejbRemove() methods. That's why we believe that
there is a slight bug inside the jonas code which prevents the exception
from being forwarded to the client. Perhaps somebody has put a try/catch
block for testing purposes and forgot to comment it out.
Could somebody please have a closer look at the problem? It prevents us from
using entity beans, which is really a big sacrifice. Sorry we can't fix the
problem ourselves, but we are not used to implement systems like jonas.
I attach an example where the problem occurs. If an SQLException is thrown
by the JDBC-Driver due to a lock on the database record, the Exception can
be seen in the server trace output and we can catch and rethrow it in our
ejbStore() implementation. (bean-managed-persistence) The bad thing is, that
jonas does not forward our exception to the client.
Thanks very much for your help!!!
*********************
Example client code:
*********************
try {
double value = 100.00;
utx.begin();
a1.setBalance(value);
a2.setBalance(-value);
utx.commit();
} catch (Exception e) {
System.err.println("exception during 1st Tx: " + e);
System.exit(2);
**********************************************
Example bean code (bean-managed persistence):
**********************************************
public void ejbStore() throws RemoteException {
if( isModified() ) {
try {
// get a connection for this transaction context
Connection conn = dataSource.getConnection();
// store Object state in DB
PreparedStatement stmt = conn.prepareStatement("update
accountsample set customer=?,balance=? where accno=?");
stmt.setString(1, customer);
stmt.setDouble(2, balance);
AccountBeanPK pk = (AccountBeanPK)
entityContext.getPrimaryKey();
stmt.setInt(3, pk.accno);
stmt.executeUpdate();
// close statement
stmt.close();
// release connection
conn.close();
setModified( false );
} catch (SQLException e) {
throw new EJBException("SQLException: Failed to store bean to
database");
}
}
}
**********************
Server trace-output:
**********************
EJBHome:samples.eb.BullAccountImplBeanAccountHome for AccountImplBean
available
Failed to store bean to database
java.sql.SQLException: Could not position within a table
(messer.accountsample).
(-107)ISAM error: record is locked.
at com.informix.jdbc.IfxSqli.errorDone(IfxSqli.java)
....
at
samples.eb.BullAccountImplBeanAccount.storeData(BullAccountImplBeanAccount.j
ava:319)
at
com.bull.ejb.EntitySynchroImpl.beforeCompletion(EntitySynchroImpl.jav
a:93)
at com.bull.jta.SubCoordinator.doBeforeCompletion(Compiled Code)
at
com.bull.jta.SubCoordinator.commit_one_phase(SubCoordinator.java:195)
at com.bull.jtm.ControlImpl.commit(ControlImpl.java:335)
at com.bull.jtm.ControlImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(Compiled Code)
...
EntitySynchroImpl.beforeCompletion() : java.rmi.RemoteException: Failed to
store bean to database; nested exception is:
java.sql.SQLException: Could not position within a table
(messer.accountsample).
(-107)ISAM error: record is locked.
*******************************************************************
DELICom DPD Deutscher Paket Dienst GmbH & Co. KG
Wailandtstrasse 1, D-63741 Aschaffenburg
Telefon: +49 / (0)6021 / 492-6039
Fax: +49 / (0)6021 / 6502
E-Mail: [EMAIL PROTECTED]
Internet: http://www.dpd.de
*******************************************************************