Re: [OJB-developers] Re: OJB in C/S mode: TransactionInProgressEx
Brought to you by:
thma
From: <ri...@ya...> - 2002-02-01 22:17:06
|
Hello, I have tried the C/S patch, and I am getting this exception when two = users try to login at the same time: ------------------------------------------------------------- [ODMG] ERROR: null org.odmg.TransactionNotInProgressException at = ojb.broker.server.PersistenceBrokerClient.commitTransaction(Persisten ceBrokerClient.java:192) at ojb.odmg.oql.OQLQueryImpl.execute(OQLQueryImpl.java:230) at = charlie.ojb.ProyectoManagerOJB.getEmpleado(ProyectoManagerOJB.java) at charlie.web.LogonAction.perform(LogonAction.java) at = org.apache.struts.action.ActionServlet.processActionPerform(ActionSer vlet.java:1787) at = org.apache.struts.action.ActionServlet.process(ActionServlet.java:158 6) 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(Appl icationFilterChain.java:247) at = org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:193) at = org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:243) at = org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566) at = org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472) at = org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at = org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:201) at = org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566) at = org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472) at = org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at = org.apache.catalina.core.StandardContext.invoke(StandardContext.java: 2344) at = org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:164) at = org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566) at = org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche rValve.java:170) at = org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:564) at = org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:170) at = org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:564) at = org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java: 462) at = org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:564) at = org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472) at = org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at = org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:163) at = org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566) at = org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472) at = org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at = org.apache.catalina.connector.http.HttpProcessor.process(HttpProcesso r.java:1011) at = org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja va:1106) at java.lang.Thread.run(Thread.java:484) -------------------------------------------------------------------------= One of the users logs in, the other gets a stack trace. I'm sure is not the singleton trying to initialize the omdg variable = twice, because I'm using the "double check idiom". These are the messages in the OJB C/S console: [ojb.broker.server.RequestProcessor] ERROR: Client tries to open tx = twice [ojb.broker.server.RequestProcessor] ERROR: = ojb.broker.server.Request@e35d5 [ojb.broker.server.RequestProcessor] ERROR: null [ojb.broker.server.RequestProcessor] ERROR: null [ojb.broker.server.RequestProcessor] ERROR: Client tries to open tx = twice [ojb.broker.server.RequestProcessor] ERROR: Client tries to open tx = twice Thanks for the Struts + OJB sample code. It's very interesting how he = passes values between Actions and OJB, using a Hashtable. Please let me know what to do next... Thanks A LOT for all your help! Ricardo Arguello ----- Original Message -----=20 From: "Thomas Mahler" <tho...@ho...> To: "Ricardo Arg=FCello" <ri...@ya...> Cc: "ojb" <obj...@li...> Sent: Friday, February 01, 2002 2:48 PM Subject: Re: [OJB-developers] Re: OJB in C/S mode: = TransactionInProgressEx Hi Ricardo attached you'll find the struts sample and a patch for the BrokerPool (for c/s) mode. Ricardo Arg=FCello wrote: > Hello, > > As I said before, when 2 users try to use the same part of the "manager", one of them gets an Exception, the other process it = correctly. > > Maybe it's because of the fact that I'm using ONE "odmg instance" (odmg=3DOJB.getInstance()) in my manager singleton. In every invocation = of a function in this manager, I use: > Transaction tx =3D odmg.newTransaction() > > So, aparently it's not a problem. But I'm not sure... It's no problem. OJB.getInstance() always returns the same instance... > > This is the complete stack trace, when 2 users access the same = function: >=20 -------------------------------------------------------------------------= > [ODMG] ERROR: null > org.odmg.QueryException > at ojb.odmg.oql.OQLQueryImpl.execute(OQLQueryImpl.java:251) > at charlie.ojb.ProyectoManagerOJB.tareasPorEmpleado(ProyectoManagerOJB.j > ava) unfortunately we don't see what's going wrong within the OQL query. Please set the loglevel for ODMG and PersistenceBrokerImpl to DEBUG and send me the result to get a clearer impression... > > > I'm NOT using OJB in C/S mode. The "TransactionInProgressException problem" was related to OJB in C/S mode, this one is ANOTHER problem, as you can see in the satck trace. > > I hope the patch helps solucionate the C/S problem, but this one seems to be another issue, am I right? > Yes, I think so. Please try out the patched c/s mode HTH, Thomas > Thanks for your help! > > > Greetings, > > > > Ricardo Arguello > ri...@ya... > > > > > > > ----- Original Message ----- > From: "Mahler Thomas" <tho...@it...> > To: "'Ricardo Arg=FCello'" <ri...@ya...>; "ojb" <obj...@li...> > Sent: Thursday, January 31, 2002 8:04 AM > Subject: AW: [OJB-developers] Re: OJB in C/S mode: TransactionInProgressEx > > > Hi again Ricardo, > > The bugfix is on the way. I hope to get it posted today! > > >>-----Urspr=FCngliche Nachricht----- >>Von: Ricardo Arg=FCello [mailto:ri...@ya...] >>Gesendet: Mittwoch, 30. Januar 2002 22:43 >>An: ojb >>Betreff: Re: [OJB-developers] Re: OJB in C/S mode: >>TransactionInProgressEx >> >> >>Hello, >> >>Thanks for your reply. >> >>I have a "manager class" wich is called from my Struts >>actions, and it does al the work, calling the "OJBed >>classes", retuning Collections, etc. >> >>This manager is a singleton, and when I instanciate it (only >>once) I initialize the "odmg" class variable: >> >>public class ProyectoManagerOJB { >> private static final String databaseName =3D >> >>PersistenceBrokerFactory.getConfiguration().getRepositoryFilename(); >> >> private Implementation odmg; // maybe this is wrong! >> > > This absolutely ok. OJB.getInstance() is a singleton > > >> public ProyectoManagerOJB() { >> odmg =3D OJB.getInstance(); >> Database db =3D odmg.newDatabase(); >> try { >> db.open(databaseName, Database.OPEN_READ_WRITE); >> } catch (ODMGException ex) { >> ex.printStackTrace(); >> } >> } >>... >>} >> >>Struts actions call functions in this class: >> >>ProyectoManager pm =3D ProyectoManager.getInstance(); // it's >>an abstract factory, returns ProyectoManagerOJB >>User user =3D pm.getUser("john"); >> >>The corresponding class in ProyectoManagerOJB is this one: >>(User is an interface, UserOJB implements it) >> >>public User getUser(String user) { >> try { >> Transaction tx =3D odmg.newTransaction(); >> tx.begin(); >> OQLQuery query =3D odmg.newOQLQuery(); >> query.create( >> "select p from " >> + charlie.ojb.UserOJB.class.getName() >> + " where user =3D \"" >> + user >> + "\""); >> DList result =3D (DList) query.execute(); >> User user =3D (User) result.get(0); >> tx.commit(); >> return user; >> } catch (Exception e) { >> e.printStackTrace(); >> return null; >> } >>} >> >>As you can see, in getUser() I use the class variable "odmg". >> > > That's OK! > > >>If I have two users login in, I get a = TransactionInProgressException. >> > > Please send me a complete stacktrace of this exception. I'm not sure if it > is a PersistenceBrokerException or an ODMGException. > > >>I believe it is because of the fact that odmg is an instance = variable. >> >>So, could you send me some code examples of your >>friends'"odmg helper class" to see how I could implement it >>in my architecture? >> >> > > I'll will post it to you later this day. > > >>Thanks in advance! >> >>Greetings from Quito, Ecuador >> >> > > greetings from Essen, Germany > > Thomas > > >>Ricardo Arguello >>ri...@ya... >> >> >>----- Original Message ----- >>From: "Thomas Mahler" <tho...@ho...> >>To: "Ricardo Arguello" <ri...@ya...>; "ojb" >><obj...@li...> >>Sent: Wednesday, January 30, 2002 3:35 PM >>Subject: [OJB-developers] Re: OJB in C/S mode: = TransactionInProgressEx >> >> >> >>>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=3D"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=3DREAD 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 >>> >>> >>> >>>_______________________________________________ >>>Objectbridge-developers mailing list >>>Obj...@li... = >>>https://lists.sourceforge.net/lists/listinfo/objectbridge-developers >>> >>> >> >> >>_______________________________________________ >>Objectbridge-developers mailing list >>Obj...@li... >>https://lists.sourceforge.net/lists/listinfo/objectbridge-developers >> >> > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > > > > |