ODMG transactions are specifically tied to threads. The behavior you see when it sometimes works is if you *happen* to get the same thread again from the servlet container. To reattach to the transaction, call Transaction.join() on it before making any changes.

Be very careful leaving an open transaction in the session -- it maintains an open database connection for the transaction. It is not difficult to chew up all database connections and get deadlocks in these cases.

-Brian

On Jul 4, 2004, at 9:08 AM, [EMAIL PROTECTED] wrote:





Hello everybody,

I am trying to implement a function with the ODMG API and Struts.

The model is a 1:n relationship between objects of two types, let's say a
class BankAccount that owns a collection of BankTransactions. In a first
page the user chooses an account to manage, then the application shows a
second page he inserts a Transaction.


To do that, I open an ODMG transaction at the beginning end store it in the
HTTP session. With this transaction I retrieve the BankAccount in the
Struts Action corresponding to the first page and I store it also in the
http session. In the second Struts action I create a new BankTransaction,
add it to my BankAccount and try to do a checkpoint() with the stored
transaction. This does not work every time.


I get a "org.odmg.TransactionNotInProgressException: Calling method needed
transaction, but no transaction found for current thread :-(". The whole
stack trace is at the end of this mail.


I looked a bit further and saw that LocalTxManager indexes the transactions
in a hashmap by the Thread that registered them. Since I am in a servlet I
have no warranty that two different http requests, as i have in my example,
are managed by the same thread and this explains why sometimes it does not
work (Actually, it works from time to time only because I am the only user
of my developement server ;-)).


I have serched the documentation and the users list, but did not find
anything about this problem. Is there anywhere a parameter that I did not
see right or is this a bug ?


Thank you

Stefano




org.odmg.TransactionNotInProgressException: Calling method needed
transaction, but no transaction found for current thread :-(
at
org.apache.ojb.odmg.LocalTxManager.getCurrentTransaction(LocalTxManager .java:50)
at
org.apache.ojb.odmg.locking.LockStrategyFactory.getIsolationLevel(LockS trategyFactory.java:83)
at
org.apache.ojb.odmg.locking.LockStrategyFactory.getStrategyFor(LockStra tegyFactory.java:54)
at
org.apache.ojb.odmg.locking.LockManagerDefaultImpl.upgradeLock(LockMana gerDefaultImpl.java:87)
at org.apache.ojb.odmg.TransactionImpl.lock(TransactionImpl.java:254)
at
org.apache.ojb.odmg.ObjectEnvelopeTable.upgradeImplicitLocksAndCheckIfC ommitIsNeeded(ObjectEnvelopeTable.java:260)
at
org.apache.ojb.odmg.ObjectEnvelopeTable.commit(ObjectEnvelopeTable.java :152)
at
org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(TransactionImpl.j ava:306)
at
org.apache.ojb.odmg.TransactionImpl.checkpoint(TransactionImpl.java: 441)
at
ch.admin.ofit.framework.persistence.ojb.odmg.PersistenceManagerOjbOdmgI mpl.storeState(PersistenceManagerOjbOdmgImpl.java:83)
at
ch.admin.formation.controler.creation.ControleurCreation.valideDecision (ControleurCreation.java:129)
at
ch.admin.formation.controler.creation.DecisionCreationEtat.transitionSu ivant(DecisionCreationEtat.java:49)
at
ch.admin.formation.controler.creation.MachineEtatsCreation.transmetTran sition(MachineEtatsCreation.java:35)
at
ch.admin.formation.struts.BusinessAction.perform(BusinessAction.java: 39)
at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServl et.java:1787)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic ationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil terChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal ve.java:256)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal ve.java:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java: 2415)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav a:180)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV alve.java:171)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav a:172)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve .java:174)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java: 594)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process Connection(Http11Protocol.java:392)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java: 565)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo l.java:619)
at java.lang.Thread.run(Thread.java:513)



--------------------------------------------------------------------- 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]



Reply via email to