Looking at your session bean examples, you throw EJBExceptions to cause a rollback. When I do the same, I now get a rollback as well. So I suppose that I can't use my custom Exceptions unless they inherit from EJBException.
Thanks very much,
Phil
Hi Phil,
indeed this should not happen. All "communication" between OJB and the container is done via the Synchronization interface implemented in J2EETransaction. In method beforeCompletion() OJB check the status off the current JTA transaction. If status is 'STATUS_MARKED_ROLLBACK' OJB itself does a rollback too, else OJB does commit (should we check more careful here?). I thought the session bean examples shipped with OJB provide a test case that does exactly what you describe (ODMGSessionBean, ODMGClient testRollback methods). These tests pass AFAIK.
regards, Armin
Phil Warrick wrote:
Hi,
I'm observing unexpected behaviour when code that is (transparently) bracketed by a j2ee transaction throws an exception. I would have expected that eventually there would be a call to J2EETransactionImpl#abort(), however it seems instead that J2EETransactionImpl#commit() is called. While this happens infrequently in my case, when it does happen (e.g. an NPE in my application code), it means a write of corrupted data. Is there a way to be certain that the container calls abort() rather than commit()? In case it matters, in my EJBBean, I catch any exception and throw another (custom) exception as in:
/** * @ejb:interface-method */ public void commitFoo(Foo serialFoo) throws MyFooException { try { log.debug("commitFoo() called"); // now modify persistent classes using // serialized input serialFoo: possible NPE getFooServer().commitFoo(serialFoo); // commit() should occur now } catch (Exception e) { log.error("commitFoo() failed", e); throw new MyFooException(e.getMessage()); // why does a commit() rather than an abort() // occur now? } }
I've left responsibility for transactions to the container so I've not thought about these details before.
Configuration: ojb-1.0.rc4, jboss 3.0.6, oracle 8.1.7
Any clues would be much appreciated,
Phil
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
