Re: [OJB-developers] Re: OJB in C/S mode: TransactionInProgressEx
Brought to you by:
thma
From: <ri...@ya...> - 2002-01-31 15:02:43
|
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... This is the complete stack trace, when 2 users access the same function: -------------------------------------------------------------------------= [ODMG] ERROR: null org.odmg.QueryException at ojb.odmg.oql.OQLQueryImpl.execute(OQLQueryImpl.java:251) at = charlie.ojb.ProyectoManagerOJB.tareasPorEmpleado(ProyectoManagerOJB.j ava) at org.apache.jsp.main$jsp._jspService(main$jsp.java:110) at = org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at = org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer vlet.java:202) at = org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 82) at = org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at = org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp atcher.java:679) at = org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD ispatcher.java:431) at = org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis patcher.java:355) at = org.apache.struts.action.ActionServlet.processActionForward(ActionSer vlet.java:1759) at = org.apache.struts.action.ActionServlet.process(ActionServlet.java:159 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) -------------------------------------------------------------------------= --- 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? Thanks for your help! Greetings, Ricardo Arguello ri...@ya... ----- Original Message -----=20 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 >=20 >=20 > Hello, >=20 > Thanks for your reply. >=20 > I have a "manager class" wich is called from my Struts=20 > actions, and it does al the work, calling the "OJBed=20 > classes", retuning Collections, etc. >=20 > This manager is a singleton, and when I instanciate it (only=20 > once) I initialize the "odmg" class variable: >=20 > public class ProyectoManagerOJB { > private static final String databaseName =3D > =20 > PersistenceBrokerFactory.getConfiguration().getRepositoryFilename(); >=20 > private Implementation odmg; // maybe this is wrong!=20 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(); > } > } > ... > } >=20 > Struts actions call functions in this class: >=20 > ProyectoManager pm =3D ProyectoManager.getInstance(); // it's=20 > an abstract factory, returns ProyectoManagerOJB > User user =3D pm.getUser("john"); >=20 > The corresponding class in ProyectoManagerOJB is this one:=20 > (User is an interface, UserOJB implements it) >=20 > 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; > } > } >=20 > As you can see, in getUser() I use the class variable "odmg".=20 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. >=20 > So, could you send me some code examples of your=20 > friends'"odmg helper class" to see how I could implement it=20 > in my architecture? >=20 I'll will post it to you later this day. > Thanks in advance! >=20 > Greetings from Quito, Ecuador >=20 greetings from Essen, Germany=20 Thomas > Ricardo Arguello > ri...@ya... >=20 >=20 > ----- Original Message -----=20 > From: "Thomas Mahler" <tho...@ho...> > To: "Ricardo Arguello" <ri...@ya...>; "ojb"=20 > <obj...@li...> > Sent: Wednesday, January 30, 2002 3:35 PM > Subject: [OJB-developers] Re: OJB in C/S mode: TransactionInProgressEx >=20 >=20 > > Hi Ricardo, > >=20 > > sorry for the trouble OJB is causing for you. > > We'll try to get a solution for this soon. > >=20 > > Ricardo Arguello wrote: > >=20 > > > Hello, > > >=20 > > > As I said before, I'm getting a=20 > > > TransactionInProgressException when I use OJB in=20 > > > Client/Server mode. > > >=20 > > > I tried changing the log to DEBUG, bit it imposibe for me=20 > > > to distinguish any of the errors, there is a LOT of DEBUG=20 > > > messages, of the following style: > > >=20 > >=20 > >=20 > >=20 > > Yup, sometimes it's hard to know which part of the system=20 > might write=20 > > the relevant log infos... > >=20 > >=20 > > >=20 > > > [ojb.broker.server.RequestProcessor] DEBUG: OJB=20 > > > RequestProcessor 2 waiting... > > > [ojb.broker.server.RequestProcessor] DEBUG: OJB=20 > > > RequestProcessor 7 working... > > > [ojb.broker.server.RequestProcessor] DEBUG: dispatching [24, > > > [ojb.broker.server.RequestProcessor] DEBUG: -1, > > > [ojb.broker.server.RequestProcessor] DEBUG: class=20 > > > charlie.ojb.EmpleadoOJB, > > > [ojb.broker.server.RequestProcessor] DEBUG: null] > > > [ojb.broker.server.BrokerPool] DEBUG: getFreeBrokerId: 1,=20 > > > remaining: [1, 1, 1, 1 > > > , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 3,=20 > > > 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,=20 > > > 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,=20 > > > 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,=20 > > > 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,=20 > > > 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,=20 > > > 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,=20 > > > 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,=20 > > > 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,=20 > > > 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,=20 > > > 1, 1, 1, 1, 1, 1, 1, > > > 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] > > >=20 > > >=20 > > > Awful, right? > >=20 > >=20 > > Yes that's awful to read. But it is also a clear indicator=20 > that there=20 > > must be a bug in the BrokerPool. It should contain exactly=20 > ten brokers=20 > > numbered from 0 - 9. > > As the list you see contains a lot of "1" entries you are=20 > served with=20 > > the same broker instance for multiple transactions. > >=20 > > This is definitely a severe bug. > >=20 > > I will start working on it asap and hope to have a fix by=20 > the weekend. > >=20 > >=20 > > >=20 > > > I cannot find the errors I metioned in my previous=20 > > > message... But my application stil acts the same: Two=20 > > > persons can't even login at the same time, one of them gets=20 > > > a stack trace... > > >=20 > >=20 > >=20 > > I assume that it is all related to the above error ! > >=20 > >=20 > > > I was reading the Locking document, and I tried to add a=20 > > > isolation=3D"read-uncommitted" to all my class definitions in=20 > > > the repository.xml file, but tha doesn't help either. > >=20 > >=20 > > This is definitely a locking problem. OJB uses read-uncommited by=20 > > default already. In the case of locking problems you would=20 > get a ODMG=20 > > LockNotGrantedException! > >=20 > > > How=20 > > > should I declare my lockings? In the XML file, in my code=20 > > > (you say the ODMG doesnt dictate a way to that). > > >=20 > >=20 > >=20 > > Locking is declared in the repository only. ODMG specifies=20 > no API for=20 > > setting locklevels. > >=20 > >=20 > > >=20 > > > Please clarify this to me? Do I need to do C/S to use OJB=20 > > > in a web application? > >=20 > >=20 > >=20 > > Hmm. I know of people who are using OJB in singlevm mode in=20 > Web apps. > > As long as the commit phase of ODMG transactions is=20 > relatively short=20 > > there won't be much problems. > >=20 > > I'm intending to have brokerpool for the singlevm mode too.=20 > then it will=20 > > be totally safe to use the singlevm mode which is much faster !!! > >=20 > >=20 > > > Wouldn't a "OJB Helper" with a single Database instance=20 > > > (singleton) be enough? > > >=20 > >=20 > >=20 > > Yes that should be sufficient. > >=20 > >=20 > > > If that's the case, how could I implement that?=20 > >=20 > >=20 > > Hmm, I'm not quite sure what you want to implement exactly? > >=20 > >=20 > > > Is OJB thread safe?=20 > >=20 > >=20 > > Yes > >=20 > > >How can I use OJB with Tomcat + Struts? > >=20 > >=20 > > A colleague of mine used Struts and the OJB ODMG api sucessfully. > > He defined special STruts actions that used ODMG=20 > transactions to do the=20 > > persistence work. It's pretty straightforward. > >=20 > > If you are interested I might post you sample code for this. > >=20 > >=20 > > > How can I assure that 2 transactions can READ at the same=20 > > > time, without locking? > > >=20 > >=20 > >=20 > > Currently the OJB ODMG implementation relies on pessimistic locking. > > There is currently no optimistic locking support. (will be=20 > there in 1.0) > >=20 > > But if you use "uncommitted-read" there should be no=20 > locking problems. > > You can do even more do avoid lock conflicts through WRITE=20 > operations. > > In OJB.properties you'll find an entry LockAssociations set=20 > this to READ. > >=20 > > The LockAssociations entry defines the behaviour for the OJB > > implicit locking feature. If set to WRITE (default)=20 > acquiring a write- > > lock on a given object x implies write locks on all objects=20 > associated > > to x. If set to READ implicit read-locks are acquired. > > Acquiring a read-lock on x thus allways results in implicit=20 > read-locks > > on all associated objects. > >=20 > > Using uncommited reads in combination with=20 > LockAssociation=3DREAD will=20 > > reduce Locking related problems to a minimum. > >=20 > > But as I said before: your problem is NOT related to locking. > >=20 > >=20 > > >=20 > > > Thanks in advance. > > >=20 > > > Ricardo Arguello (an ex-Castor refugee) > >=20 > >=20 > > I'll work hard to ensure you won't become an OJB refugee ;-) > >=20 > >=20 > > cu, > >=20 > > Thomas > >=20 > >=20 > >=20 > > _______________________________________________ > > Objectbridge-developers mailing list > > Obj...@li... > > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > >=20 >=20 >=20 >=20 > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers >=20 _______________________________________________ Objectbridge-developers mailing list Obj...@li... https://lists.sourceforge.net/lists/listinfo/objectbridge-developers |