joining in a query
Let's say I have the following 3 tables: customer purchase order purchase order lines Each purchase order line has a reference to a purchase order. Each purchase order has a reference to customer. I want to do a query where I retreive all purchase order lines sorted by customer name (among other things). When I try this, OJB handles the join between purchase order lines and purchase order, but doesn't join the customer table. Is there a way I can force it to include the customer in the query? When I did the addOrderBy, I specified "purchaseorder.customer.name" but when OJB created the SQL, it changed that to "name", but didn't specify an alias for the field and didn't include customer in the from or where clauses. It did join the purchase order lines and the purchase order table. Thanks Jay - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
commons-lang 1_0_1 and 2_0
Hi, I am trying to use a Struts1.1 and OJB1.1RC7 application but I am facing with the problem that commons-lang1_0_1 doesn't have some classes that OJB uses (like java.lang.NoClassDefFoundError: org/apache/commons/lang/BooleanUtils). If I switch from one version of commons-lang to another one of the packages stop working. I tried both libs on /WEB-INF/lib and OJB doesn't correctly. Is there any way around this (without recompiling/modifying one of the sources)? Pedro Salgado - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: object in QueryByCriteria
thanks a lot for your hint, now the statements are generated as expected :-) Marc On Mon, 16 Aug 2004 17:11:22 -0600 Ashish Rangole <[EMAIL PROTECTED]> wrote: > My guess is your attributes have primitive types. That > is, oUser.id has type int rather than Integer. If you > use the later then just do not set the attribute that > you do not want to use in criteria and since it will then be null, > it won't be looked at. > > Ashish > > > > Marc Tinnemeyer wrote: > > Dear Listmembers, > > > > I got the following problem: > > > > I try to retrieve an object via ojb using the PB API. The syntax > > looks like this: > > > > broker = PersistenceBrokerFactory.defaultPersistenceBroker(); > > QueryByCriteria query = new QueryByCriteria(oUser); > > result = (User) broker.getObjectByQuery(query); > > > > the oUser object has several attributes, like id, name, username, > > password ... > > > > Now somebody tries to login and the attributes "username" and > > password" are set. That object ist then passed as criteria to > > QueryByCriteria. > > > > The weird thing is that the generated sql-statement looks like > > this: > > > > SELECT > > A0.username,A0.password,A0.id > > WHERE (((A0.id = 0) AND A0.username = 'userabc') > > AND A0.password = 'myPassword') > > > > My problem is A0.id = 0 ! > > And my question is, is there a way to tell ojb only to query the > > attributes that are set ? > > s.th. like: > > > > select > > A0.username,A0.password,A0.id > > where (( A0.username = 'abcUser') and A0.password = 'myPassword') > > > > Currently my version of ojb is 1.0rc6. > > > > > > Thanks in advance, > > > > Kind regards, > > Marc Tinnemeyer > > > > -- > > --- 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] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: can i use cloudscape?
Chances are Cloudscape will work with the Default database impl, just reuce JDBC level until it works (that is how I am doing Axion at the moment, for example). I expect once we get Derby people on board we will build explicit support in. -Brian On Aug 17, 2004, at 11:30 AM, Charles Anthony wrote: Hi, OJB does not support Cloudscape "out-of-the-box", no, although one probably could make OJB support it. It does support HSQLDB, though, which is another open-source just-java database. Cheers, Charles. -Original Message- From: Saurabh Bhatla [mailto:[EMAIL PROTECTED] Sent: 17 August 2004 16:27 To: OJB Subject: can i use cloudscape? Hi all, Can i use cloudscape with ojb or do i need to use some other persistence frame work. Please help as i need to make a decision soon. regards saurabh - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ___ HPD Software Ltd. - Helping Business Finance Business Email terms and conditions: www.hpdsoftware.com/disclaimer - 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]
RE: can i use cloudscape?
Hi, OJB does not support Cloudscape "out-of-the-box", no, although one probably could make OJB support it. It does support HSQLDB, though, which is another open-source just-java database. Cheers, Charles. > -Original Message- > From: Saurabh Bhatla [mailto:[EMAIL PROTECTED] > Sent: 17 August 2004 16:27 > To: OJB > Subject: can i use cloudscape? > > > Hi all, > Can i use cloudscape with ojb or do i need to use some other > persistence frame work. Please help as i need to make a decision soon. > regards > saurabh > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > ___ HPD Software Ltd. - Helping Business Finance Business Email terms and conditions: www.hpdsoftware.com/disclaimer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Collection of derived classes
Hi, I'm using ojb-1.0.0 and like to retrieve/modify a collection of derived classes. I've got problems with updating of values of the derived classes and understanding the super/extent/ojbConcreteClass-construct. The collection classes have the following layout: class Top {} class Child1 extends Top { // collection of a concrete class } class Group extends Top {} class Child2 extends Group { // collection of a concrete class } class Child3 extends Group { // collection of a concrete class } And there's a container class which references any of the "Child*"-classes as composite classes. class Container { /** * @ojb.collection *element-class-ref="Top" *foreignKey="contId" *auto-retrieve="true" *auto-update="object" *auto-delete="object" **/ List children = new ArrayList(); } I've mapped the derived classes by the multiple-joined-table method - but it also could be the "Mapping each class to a distinct table" method, but I haven't tried it. Every subclass has a super-reference to its' parent class and has the same primary key. The primary key is an anonymous autoincrement field, which is inherited through the hierarchy. All other inherited fields are hidden through a xdoclet-"@ojb.modify-inherited name=... ignore=true". Furthermore, every subclass has a anonymous field for the foreign key to the container class (i.e. "contId"). I've played with the xdoclet-class-option "determine-extents" and have activated it (determine-extents=true) in the moment - there's also the ojbConcreteClass-feature in all of the parent-classes activated. None of the classes uses proxies. When I use the PB-API with the PersistentFieldIntrospectorImplNew-field access i'll get the following results: - insert of a new container object with children: Everything is inserted, but the foreign key field "contId" is only filled in the child-classes - the value in the parent classes is null. - query/select ot the container object: If the extent-info in the reposity is missing - none of the children is loaded, because the foreign key can't be matched to the container object. Otherwise the select-statements are chained to the subclasses until the foreign key references are filled - all children are loaded. If a manually update the foreign key column in the parent classes to the right id, I'll end up with an instance for every hierarchical entry (i.e. I want: (child1, child2, child3); I'll get: (1*child1, 3*child2, 3*child3)) - update of the collection: After loading the container and its children with the extents, i've changed a few fields. The following store-operation saved the changes in the container successfully, but none of the children were changed. - ojbConcreteClass db-field isn't evaluated: The ojbConcreteClass field is stored in the db (as "CLASS_NAME"-field). When ojb tries to fetch the children objects it seems that it checks which classes have an objConcreteClass-member (here: only the parent classes - TOP and Group). Then it only asks for these classes in the where-clause: "... where contId = ... and class_name in ('Top', 'Group')", instead of evaluating the "CLASS_NAME"-field and instanciating the right class. This problem can only be solved if all classes have the ojbConcreteClass-member, then the where-clause looks like " ... class_name in ('TOP', 'CHILD1', ...)" Furthermore, I've noticed that if the ojbConcreteClass-feature is used and a null-value is read from the db, the default RowReaderImpl doesn't use the field conversion specified for that field. (RowReaderDefaultImpl:122) Questions: - Most of the time I'll load the whole object tree with only a few top level (i.e. container)-criterias. Besides performance, does it make any difference if I use the "multiple joined tables" or "distinct table" method? - Can proxies be used with "multiple joined tables"-collections? (Haven't tried it yet, because I want to get it working without proxies first ...) - Why does XDoclet require to have a foreign key member in the parent classes if it's only filled in the child classes? Thanks. Andreas. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
can i use cloudscape?
Hi all, Can i use cloudscape with ojb or do i need to use some other persistence frame work. Please help as i need to make a decision soon. regards saurabh - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: object in QueryByCriteria
hi all, when using primitives ojb canot distinguish int 0 from an uninitialized int (0 as well), so it's better not to use primitives at all. hth jakob > My guess is your attributes have primitive types. That > is, oUser.id has type int rather than Integer. If you > use the later then just do not set the attribute that > you do not want to use in criteria and since it will then be null, > it won't be looked at. > > Ashish > > > > Marc Tinnemeyer wrote: > > Dear Listmembers, > > > > I got the following problem: > > > > I try to retrieve an object via ojb using the PB API. The syntax looks > > like this: > > > > broker = PersistenceBrokerFactory.defaultPersistenceBroker(); > > QueryByCriteria query = new QueryByCriteria(oUser); > > result = (User) broker.getObjectByQuery(query); > > > > the oUser object has several attributes, like id, name, username, > > password ... > > > > Now somebody tries to login and the attributes "username" and password" > > are set. That object ist then passed as criteria to QueryByCriteria. > > > > The weird thing is that the generated sql-statement looks like this: > > > > SELECT > > A0.username,A0.password,A0.id > > WHERE (((A0.id = 0) AND A0.username = 'userabc') > > AND A0.password = 'myPassword') > > > > My problem is A0.id = 0 ! > > And my question is, is there a way to tell ojb only to query the > > attributes that are set ? > > s.th. like: > > > > select > > A0.username,A0.password,A0.id > > where (( A0.username = 'abcUser') and A0.password = 'myPassword') > > > > Currently my version of ojb is 1.0rc6. > > > > > > Thanks in advance, > > > > Kind regards, > > Marc Tinnemeyer > > > > - > > 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] > -- NEU: WLAN-Router für 0,- EUR* - auch für DSL-Wechsler! GMX DSL = supergünstig & kabellos http://www.gmx.net/de/go/dsl - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ConcurrentModification!!!
Tino Schöllhorn wrote: Hi Armin, how do I make sure that different threads get different connections? Each PB instance use its own connection, so if you use a PB instance per thread, OJB automatic use its own connection instance per PB instance. I get my PB instances form a helper method: public static PersistenceBroker getPBFromAlias(String jcdAlias) { ===> MetadataManager mm = MetadataManager.getInstance(); ConnectionRepository cr = mm.connectionRepository(); PBKey pbKey = cr.getStandardPBKeyForJcdAlias(jcdAlias); if (pbKey == null) { throw new RuntimeException( "Konnte keinen PersistenceBroker zu alias '" + jcdAlias + "' finden!" ); } ===> Why not simply: PBKey pbKey = new PBKey(jcdAlias); PersistenceBroker res = PersistenceBrokerFactory.createPersistenceBroker(pbKey); or PersistenceBroker res = PersistenceBrokerFactory.createPersistenceBroker(jcdAlias, null, null); return res; } regards, Armin I am invoking this method in different threads? Do I have to synchronize this method? Tino Armin Waibel wrote: Hi Tino, are you sure that the used PB instance was not shared across different threads? The PB itself is not threadsafe, each thread has to use its own instance of PB obtained from the PBF. >> java.util.ConcurrentModificationException >> at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) >> at java.util.HashMap$KeyIterator.next(HashMap.java:818) >> at >> org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown Source) private void pushToRealCache() { Iterator it = localCache.keySet().iterator(); Identity oid; while (it.hasNext()) { oid = (Identity) it.next(); realCache.cache(oid, localCache.get(oid)); } localCache.clear(); } You can see from the code snip that a ConcurrentModificationException can occur when different threads using the same PB instance (each PB has an own instance of InternalCache). regards, Armin Tino Schöllhorn wrote: I forgot to mention that we are using OJB 1.0 ! Tino Schöllhorn wrote: Hi, we are using OJB in a Tomcat-Application and are greatly satisfied. Now we are moving our application to a windows 2003 server with 2 processors and we encounter some problems. One is the following: We implemented a DownloadServlet which is responsible for delivering Streams of previously uploaded files. But on this machine we get errors when downloading some files (the thing is: sometimes it is ok, sometimes it is not). Here is the Stacktrace which I think could be responsible to this problem: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) at java.util.HashMap$KeyIterator.next(HashMap.java:818) at org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown Source) at org.apache.ojb.broker.cache.InternalCache.disableMaterializationCache(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at kos.generator.DataObject.getObjectById(DataObject.java:368) at kos.wnetz.om.base.File.getFileById(File.java:156) at kos.wnetz.modules.fs2.DownloadServlet.doGet(DownloadServlet.java:34) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) Do you have any ideas how this error could be prevented? Is this a synchronization-problem of OJB? I will try to synchonize our DownloadServlet - but due to performance-reasons this is not our preferred solution (;-)) With regards Tino - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problems with TM in ejbCreate() --- continued
Hi Dino, sorry forget to reply. I checked in an attempt to fix your problem in CVS trunk and 1.0_RELEASE branch. http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]&msgNo=8730 or http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]&msgNo=8731 Replace your files with the modified ones. Hope the made changes will fix your problem. regards, Armin Dino Di Cola wrote: Armin, This problem was driving me crazy... finally I rightfully decided to ask for your support again. I really Hope to find a solution by tomorrow ;) cause I am getting too late with this matter :( Thanks in advance! d. -- Hi Dino, I'm working on this, the patch has some unexpected side-effects in managed environments ;-) Hope to find a solution till tomorrow. regards, Armin Dino Di Cola wrote: Dear Armin, I am testing your patch on ImplementationJTAImpl#registerOpenDatabase. The problems regarding the ejbCreate() method disappeared. Unfortunately I got some problems with the org.odmg.Database#deletePersistent now. Again this problem is related to Transaction Management and was not present with the previous Oracle9iAS 9.0.2.2 version. The test case I present here is again a simple J2EE application made up of a test stateless session bean with a single business method invoked via RMI. The configuration is the same of the previous e-mail. What I am trying to do is basically to lookup for an object (es. SentMail) and deleting it with the Database#deletePersistent method: /* this is done in ejbCreate()... */ org.odmg.Implementation odmg = OJB.getInstance(); org.odmg.Database db = odmg.newDatabase(); db.open(DEF_DATABASE_NAME, Database.OPEN_READ_WRITE); [...] /* this is done in the business method... */ SentMail objSentMail = (SentMail) lookupObject(SentMail.class, 4); db.deletePersistent(objSentMail); The object is actually found on the DB but when I try to delete it I got the following exception: [exec] The following exception has been catched: Transaction was rolled back: org.odmg.TransactionNotInProgressException: No transaction in progress, cannot delete persistent; nested exception is: [exec] com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: org.odmg.TransactionNotInProgressException: No transaction in progress, cannot delete persistent [exec] org.odmg.TransactionNotInProgressException: No transaction in progress, cannot delete persistent [exec] at OJB_Tx_StatelessSessionBeanWrapper76.test(OJB_Tx_StatelessSessionBeanWrapper76.java:164) [exec] at java.lang.reflect.Method.invoke(Native Method) [exec] at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119) [exec] at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48) [exec] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:804) [exec] at java.lang.Thread.run(Thread.java:479) [exec] at connection to c-01-091/10.2.20.20 as admin [exec] at com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMIConnection.java:1576) [exec] at com.evermind.server.rmi.RMIConnection.invokeMethod(RMIConnection.java:1529) [exec] at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:55) [exec] at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:22) [exec] at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:50) [exec] at __Proxy5.test(Unknown Source) [exec] at it.enidata.psv.test.ejb.client.TestOJB_Tx.main(TestOJB_Tx.java:45) [exec] [exec] Nested exception is: [exec] org.odmg.TransactionNotInProgressException: No transaction in progress, cannot delete persistent [exec] at org.apache.ojb.odmg.DatabaseImpl.deletePersistent(Unknown Source) [exec] at it.enidata.psv.test.ejb.OJB_TxBean.test(OJB_TxBean.java:144) [exec] at OJB_Tx_StatelessSessionBeanWrapper76.test(OJB_Tx_StatelessSessionBeanWrapper76.java:115) [exec] at java.lang.reflect.Method.invoke(Native Method) [exec] at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119) [exec] at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48) [exec] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:804) [exec] at java.lang.Thread.run(Thread.java:479) [exec] at connection to c-01-091.prirm.pride.it/10.2.20.20 [exec] at com.evermind.server.rmi.OrionRemoteException.receive(OrionRemoteException.java:130) [exec] at com.evermind.server.rmi.RMIConnection.handleMethodInvocationResponse(RMIConnection.java:1691) [exec] at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:532) [exec] at com.evermind.server.rmi.RMIConnection.run(RM
Re: ConcurrentModification!!!
Hi Armin, how do I make sure that different threads get different connections? I get my PB instances form a helper method: public static PersistenceBroker getPBFromAlias(String jcdAlias) { MetadataManager mm = MetadataManager.getInstance(); ConnectionRepository cr = mm.connectionRepository(); PBKey pbKey = cr.getStandardPBKeyForJcdAlias(jcdAlias); if (pbKey == null) { throw new RuntimeException( "Konnte keinen PersistenceBroker zu alias '" + jcdAlias + "' finden!" ); } PersistenceBroker res = PersistenceBrokerFactory.createPersistenceBroker(pbKey); return res; } I am invoking this method in different threads? Do I have to synchronize this method? Tino Armin Waibel wrote: Hi Tino, are you sure that the used PB instance was not shared across different threads? The PB itself is not threadsafe, each thread has to use its own instance of PB obtained from the PBF. >> java.util.ConcurrentModificationException >> at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) >> at java.util.HashMap$KeyIterator.next(HashMap.java:818) >> at >> org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown Source) private void pushToRealCache() { Iterator it = localCache.keySet().iterator(); Identity oid; while (it.hasNext()) { oid = (Identity) it.next(); realCache.cache(oid, localCache.get(oid)); } localCache.clear(); } You can see from the code snip that a ConcurrentModificationException can occur when different threads using the same PB instance (each PB has an own instance of InternalCache). regards, Armin Tino Schöllhorn wrote: I forgot to mention that we are using OJB 1.0 ! Tino Schöllhorn wrote: Hi, we are using OJB in a Tomcat-Application and are greatly satisfied. Now we are moving our application to a windows 2003 server with 2 processors and we encounter some problems. One is the following: We implemented a DownloadServlet which is responsible for delivering Streams of previously uploaded files. But on this machine we get errors when downloading some files (the thing is: sometimes it is ok, sometimes it is not). Here is the Stacktrace which I think could be responsible to this problem: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) at java.util.HashMap$KeyIterator.next(HashMap.java:818) at org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown Source) at org.apache.ojb.broker.cache.InternalCache.disableMaterializationCache(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at kos.generator.DataObject.getObjectById(DataObject.java:368) at kos.wnetz.om.base.File.getFileById(File.java:156) at kos.wnetz.modules.fs2.DownloadServlet.doGet(DownloadServlet.java:34) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) Do you have any ideas how this error could be prevented? Is this a synchronization-problem of OJB? I will try to synchonize our DownloadServlet - but due to performance-reasons this is not our preferred solution (;-)) With regards Tino - 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]
Re: ConcurrentModification!!!
Hi Tino, are you sure that the used PB instance was not shared across different threads? The PB itself is not threadsafe, each thread has to use its own instance of PB obtained from the PBF. >> java.util.ConcurrentModificationException >> at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) >> at java.util.HashMap$KeyIterator.next(HashMap.java:818) >> at >> org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown Source) private void pushToRealCache() { Iterator it = localCache.keySet().iterator(); Identity oid; while (it.hasNext()) { oid = (Identity) it.next(); realCache.cache(oid, localCache.get(oid)); } localCache.clear(); } You can see from the code snip that a ConcurrentModificationException can occur when different threads using the same PB instance (each PB has an own instance of InternalCache). regards, Armin Tino Schöllhorn wrote: I forgot to mention that we are using OJB 1.0 ! Tino Schöllhorn wrote: Hi, we are using OJB in a Tomcat-Application and are greatly satisfied. Now we are moving our application to a windows 2003 server with 2 processors and we encounter some problems. One is the following: We implemented a DownloadServlet which is responsible for delivering Streams of previously uploaded files. But on this machine we get errors when downloading some files (the thing is: sometimes it is ok, sometimes it is not). Here is the Stacktrace which I think could be responsible to this problem: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) at java.util.HashMap$KeyIterator.next(HashMap.java:818) at org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown Source) at org.apache.ojb.broker.cache.InternalCache.disableMaterializationCache(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at kos.generator.DataObject.getObjectById(DataObject.java:368) at kos.wnetz.om.base.File.getFileById(File.java:156) at kos.wnetz.modules.fs2.DownloadServlet.doGet(DownloadServlet.java:34) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) Do you have any ideas how this error could be prevented? Is this a synchronization-problem of OJB? I will try to synchonize our DownloadServlet - but due to performance-reasons this is not our preferred solution (;-)) With regards Tino - 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]
Re: ConcurrentModification!!!
Try not to modify the HashMap whilt iterating through it. perform the operations on the iterator itself. I had same prob with a list - i used iterator to find objects to remove then removed them from the list rather than the iterator and had the same error - Original Message - From: "Tino Schöllhorn" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, August 17, 2004 11:18 AM Subject: Re: ConcurrentModification!!! > I forgot to mention that we are using OJB 1.0 ! > > Tino Schöllhorn wrote: > > > Hi, > > > > we are using OJB in a Tomcat-Application and are greatly satisfied. Now > > we are moving our application to a windows 2003 server with 2 processors > > and we encounter some problems. One is the following: > > > > We implemented a DownloadServlet which is responsible for delivering > > Streams of previously uploaded files. But on this machine we get errors > > when downloading some files (the thing is: sometimes it is ok, sometimes > > it is not). Here is the Stacktrace which I think could be responsible to > > this problem: > > > > java.util.ConcurrentModificationException > > at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) > > at java.util.HashMap$KeyIterator.next(HashMap.java:818) > > at org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown > > Source) > > at > > org.apache.ojb.broker.cache.InternalCache.disableMaterializationCache(Unknow n > > Source) > > at > > org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown > > Source) > > at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) > > at > > org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown > > Source) > > at > > org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unkn own > > Source) > > at > > org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unkn own > > Source) > > at kos.generator.DataObject.getObjectById(DataObject.java:368) > > at kos.wnetz.om.base.File.getFileById(File.java:156) > > at kos.wnetz.modules.fs2.DownloadServlet.doGet(DownloadServlet.java:34) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) > > > > > > Do you have any ideas how this error could be prevented? Is this a > > synchronization-problem of OJB? I will try to synchonize our > > DownloadServlet - but due to performance-reasons this is not our > > preferred solution (;-)) > > > > With regards > > Tino > > > - > 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]
Re: ConcurrentModification!!!
I forgot to mention that we are using OJB 1.0 ! Tino Schöllhorn wrote: Hi, we are using OJB in a Tomcat-Application and are greatly satisfied. Now we are moving our application to a windows 2003 server with 2 processors and we encounter some problems. One is the following: We implemented a DownloadServlet which is responsible for delivering Streams of previously uploaded files. But on this machine we get errors when downloading some files (the thing is: sometimes it is ok, sometimes it is not). Here is the Stacktrace which I think could be responsible to this problem: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) at java.util.HashMap$KeyIterator.next(HashMap.java:818) at org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown Source) at org.apache.ojb.broker.cache.InternalCache.disableMaterializationCache(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at kos.generator.DataObject.getObjectById(DataObject.java:368) at kos.wnetz.om.base.File.getFileById(File.java:156) at kos.wnetz.modules.fs2.DownloadServlet.doGet(DownloadServlet.java:34) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) Do you have any ideas how this error could be prevented? Is this a synchronization-problem of OJB? I will try to synchonize our DownloadServlet - but due to performance-reasons this is not our preferred solution (;-)) With regards Tino - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ConcurrentModification!!!
Hi, we are using OJB in a Tomcat-Application and are greatly satisfied. Now we are moving our application to a windows 2003 server with 2 processors and we encounter some problems. One is the following: We implemented a DownloadServlet which is responsible for delivering Streams of previously uploaded files. But on this machine we get errors when downloading some files (the thing is: sometimes it is ok, sometimes it is not). Here is the Stacktrace which I think could be responsible to this problem: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782) at java.util.HashMap$KeyIterator.next(HashMap.java:818) at org.apache.ojb.broker.cache.InternalCache.pushToRealCache(Unknown Source) at org.apache.ojb.broker.cache.InternalCache.disableMaterializationCache(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at kos.generator.DataObject.getObjectById(DataObject.java:368) at kos.wnetz.om.base.File.getFileById(File.java:156) at kos.wnetz.modules.fs2.DownloadServlet.doGet(DownloadServlet.java:34) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) Do you have any ideas how this error could be prevented? Is this a synchronization-problem of OJB? I will try to synchonize our DownloadServlet - but due to performance-reasons this is not our preferred solution (;-)) With regards Tino - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]