While upgrading to Jonas 2.3 I have discovered following bug
When you try to create entity bean, which already exists, the
DuplicateKeyException is not thrown, only the basic CreateException. This is
causing problems when you have multiple clients try to create some entity,
only one will succeed and others try to recover (by catching
DuplicateKeyException) and grab the newly created entity.
The problem is in the code generated by GenIC, e.g.
public com.compuware.cgf.beans.id.IDGeneratorKey
ejbCreate(com.compuware.cgf.beans.id.IDGeneratorKey p1) throws
javax.ejb.CreateException {
...
try {
DataSource ds = (DataSource)(this.ejbHome.getDataSource());
conn = ds.getConnection();
pStmt = conn.prepareStatement("insert into T_ID_GENERATOR
(DOCTYPE, SCOPE, LAST_USED_ID) values (?, ?, ?)");
pStmt.setInt(1, this.m_iEntityType);
pStmt.setInt(2, this.m_iScopeID);
pStmt.setInt(3, this.m_iLastUsedID);
pStmt.executeUpdate();
} catch (Exception e) {
TraceEjb.error("Failed to create bean in database", e);
throw new javax.ejb.CreateException(e.toString());
} finally {
...
}
As you can see, every caught exception is thrown as CreateException. I don't
know enough about internal of JOnas but what should happen after Exception
is caught is to check (probably some internal cache or database) if the bean
with that primary key already exists and then throw either
DuplicateKeyException or just the regular CreateException.
Does this sounds reasonable?
Miro Halas
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".