[OJB-developers] Re: OJB in C/S mode: TransactionInProgressEx
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2002-01-30 20:47:32
|
Hi Ricardo, sorry for the trouble OJB is causing for you. We'll try to get a solution for this soon. Ricardo Arguello wrote: > Hello, > > As I said before, I'm getting a > TransactionInProgressException when I use OJB in > Client/Server mode. > > I tried changing the log to DEBUG, bit it imposibe for me > to distinguish any of the errors, there is a LOT of DEBUG > messages, of the following style: > Yup, sometimes it's hard to know which part of the system might write the relevant log infos... > > [ojb.broker.server.RequestProcessor] DEBUG: OJB > RequestProcessor 2 waiting... > [ojb.broker.server.RequestProcessor] DEBUG: OJB > RequestProcessor 7 working... > [ojb.broker.server.RequestProcessor] DEBUG: dispatching [24, > [ojb.broker.server.RequestProcessor] DEBUG: -1, > [ojb.broker.server.RequestProcessor] DEBUG: class > charlie.ojb.EmpleadoOJB, > [ojb.broker.server.RequestProcessor] DEBUG: null] > [ojb.broker.server.BrokerPool] DEBUG: getFreeBrokerId: 1, > remaining: [1, 1, 1, 1 > , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 3, > 1, 1, 1, 1, 1, 1, 3, > 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1 > , 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 5, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, > 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 1, 1, 1, 8, > 1, 1, 1, 9, 1, 1, 9, 1 > , 1, 1, 1, 1, 1, 0, 1, 9, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, > 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1 > , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] > > > Awful, right? Yes that's awful to read. But it is also a clear indicator that there must be a bug in the BrokerPool. It should contain exactly ten brokers numbered from 0 - 9. As the list you see contains a lot of "1" entries you are served with the same broker instance for multiple transactions. This is definitely a severe bug. I will start working on it asap and hope to have a fix by the weekend. > > I cannot find the errors I metioned in my previous > message... But my application stil acts the same: Two > persons can't even login at the same time, one of them gets > a stack trace... > I assume that it is all related to the above error ! > I was reading the Locking document, and I tried to add a > isolation="read-uncommitted" to all my class definitions in > the repository.xml file, but tha doesn't help either. This is definitely a locking problem. OJB uses read-uncommited by default already. In the case of locking problems you would get a ODMG LockNotGrantedException! > How > should I declare my lockings? In the XML file, in my code > (you say the ODMG doesnt dictate a way to that). > Locking is declared in the repository only. ODMG specifies no API for setting locklevels. > > Please clarify this to me? Do I need to do C/S to use OJB > in a web application? Hmm. I know of people who are using OJB in singlevm mode in Web apps. As long as the commit phase of ODMG transactions is relatively short there won't be much problems. I'm intending to have brokerpool for the singlevm mode too. then it will be totally safe to use the singlevm mode which is much faster !!! > Wouldn't a "OJB Helper" with a single Database instance > (singleton) be enough? > Yes that should be sufficient. > If that's the case, how could I implement that? Hmm, I'm not quite sure what you want to implement exactly? > Is OJB thread safe? Yes >How can I use OJB with Tomcat + Struts? A colleague of mine used Struts and the OJB ODMG api sucessfully. He defined special STruts actions that used ODMG transactions to do the persistence work. It's pretty straightforward. If you are interested I might post you sample code for this. > How can I assure that 2 transactions can READ at the same > time, without locking? > Currently the OJB ODMG implementation relies on pessimistic locking. There is currently no optimistic locking support. (will be there in 1.0) But if you use "uncommitted-read" there should be no locking problems. You can do even more do avoid lock conflicts through WRITE operations. In OJB.properties you'll find an entry LockAssociations set this to READ. The LockAssociations entry defines the behaviour for the OJB implicit locking feature. If set to WRITE (default) acquiring a write- lock on a given object x implies write locks on all objects associated to x. If set to READ implicit read-locks are acquired. Acquiring a read-lock on x thus allways results in implicit read-locks on all associated objects. Using uncommited reads in combination with LockAssociation=READ will reduce Locking related problems to a minimum. But as I said before: your problem is NOT related to locking. > > Thanks in advance. > > Ricardo Arguello (an ex-Castor refugee) I'll work hard to ensure you won't become an OJB refugee ;-) cu, Thomas |