Oh, so it's just a matter of wrong header on the message. Thanks a lot Armin. As always, you are very helpful. Regards, -Vamsi
----- Original Message ---- From: Armin Waibel <[EMAIL PROTECTED]> To: OJB Users List <[email protected]> Sent: Thursday, May 4, 2006 2:08:42 PM Subject: Re: Help needed for OJB transactions Vamsi Atluri wrote: > Hi Armin, > > Thanks a lot for your response. Currently, my code looks like this: > > javax.transaction.UserTransaction userTx = null; > PersistenceBroker broker = null; > > try { > InitialContext initCtx = new InitialContext(); > userTx = (UserTransaction)initCtx.lookup("java:comp/UserTransaction"); > userTx.begin(); > > broker = PersistenceBrokerFactory.defaultPersistenceBroker(); > > broker.store(objA); > broker.store(objB); > broker.deleteByQuery(someQuery); > broker.store(objC); > > userTx.commit(); > } catch(Exception e) { > userTx.rollback(); > } finally { > if(null != broker) { > broker.close(); > } > } > > Now, the warning message I reported before doesn't occur on each store call > anymore. However, whenever there is an error and I attempt a transaction roll > back, I get this: > > [org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl$PersistenceBrokerSyncImpl] > ERROR: Abort PB-tx, status of JTA tx is STATUS_ROLLEDBACK > > Why would this happen? Any ideas? Any help is greatly appreciated. > This error signals that the JTA transaction was rolled back and that OJB abort/cleanup its local PB-tx too. This is the expected behavior when JTA-tx rollback. Thus you are on the right track ;-) In latest version of OJB the log level of this message is changed to 'DEBUG' and will no longer bother you. You can find all this stuff in PersistenceBrokerFactorySyncImpl. regards, Armin > Thanks and regards, > -Vamsi > > ----- Original Message ---- > From: Armin Waibel <[EMAIL PROTECTED]> > To: OJB Users List <[email protected]> > Sent: Thursday, May 4, 2006 12:45:28 PM > Subject: Re: Help needed for OJB transactions > > > Hi Vamsi, > > Vamsi Atluri wrote: >> Hello all, >> >> I am having problems with OJB transactions. I am currently using OJB1.0.1 on >> WSAD 5.1.2 using JDK 1.3.1. >> >> My settings and code are as follows: >> >> useAutoCommit="0" >> ignoreAutoCommitExceptions="false" >> >> PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl >> ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl >> >> And the code looks as follows(I am using WSAD 5.1.2): >> >> javax.transaction.UserTransaction userTx = null; >> try { >> InitialContext initCtx = new InitialContext(); >> userTx = (UserTransaction)initCtx.lookup("java:comp/UserTransaction"); >> userTx.begin(); >> >> broker.store(objA); >> broker.store(objB); >> broker.deleteByQuery(someQuery); >> broker.store(objC); >> >> userTx.commit(); >> } catch(Exception e) { >> userTx.rollback(); >> } >> >> But whenever I am calling broker.store(), I am getting the following warning >> on the console: >> >> [org.apache.ojb.broker.core.PersistenceBrokerImpl] WARN: No running tx >> found, please only store in context of an PB-transaction, to avoid >> side-effects - e.g. when rollback of complex objects >> > > It seems you lookup the broker instance before you start the > UserTransaction. In this case OJB can't synchronize the broker instance > with the tx. Please create the broker instance after the UserTransaction > starts and see what happens. > > regards, > Armin > > >> Now, it appears to me that the broker.store() is not going through the >> transaction. Am I doing something wrong?? >> >> Also, a very strange thing happened today. I had a large amount of data to >> store and it was taking a long time and the transaction timed out after 120 >> seconds. Is this possibly because the user transaction started and none of >> the broker store calls are going through it. BUT, the strangest thing I have >> found is if any error occurs, the store calls ARE rolling back, so they are >> part of SOME transaction. Also, where is the 120 seconds setting coming >> from? I thought transactions are not supposed to time out during activity! >> >> This is getting very confusing. Can anyone throw some light on my situation? >> Any help is greatly appreciated. Thanks. >> >> Regards, >> -Vamsi > > --------------------------------------------------------------------- > 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]
