Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: JDO
-
Labels:None
-
Environment:Windows XP, Tomcat 5.5, Castor 1.1, Ehcache 1.3 beta, MySQL 5.1beta
Description
Hello,
Iīm trying to make castor and ehcache to work with Tomcat in a distributed environment and Iīm finding several different problems. Attached you can find a demo application and instruction to reproduce the problems.
Sorry I canīt create a standard testcase but I was not able to reproduc the problem out side my environment so I did try to remove all the unided classes in my project to make it as simple as possible.
Extract the zip file and open the readme.txt file where I try to explain step by step the different processes.
Thanks and regards,
Gonzalo Abollado.
-
Hide
- castorehcache.zip
- 08/May/07 1:29 PM
- 3.52 MB
- Gonzalo Abollado
-
- castorehcache/build.xml 2 kB
- castorehcache/castorehcache.iml 3 kB
- castorehcache/castorehcache.ipr 16 kB
- castorehcache/castorehcache.iws 36 kB
- castorehcache/etc/castor.properties 9 kB
- castorehcache/etc/castor_config.xml 0.7 kB
- castorehcache/etc/ehcache.xml 15 kB
- castorehcache/etc/ehcache.xsd 4 kB
- castorehcache/etc/log4j.properties 1 kB
- castorehcache/etc/mapping/User.xml 0.8 kB
- castorehcache/etc/mapping.xml 0.1 kB
- castorehcache/etc/web.xml 0.5 kB
- castorehcache/mysql.sql 2 kB
- castorehcache/README.txt 22 kB
- castorehcache/src/.../AbsCastorDataBase.java 5 kB
- castorehcache/src/.../CastorHelper.java 2 kB
- castorehcache/src/.../AbsMbookDataBase.java 0.6 kB
- castorehcache/src/com/.../base/UserBase.java 1 kB
- castorehcache/src/.../TestHelper.java 2 kB
- castorehcache/src/.../EHCache.java 13 kB
- castorehcache/src/org/.../spi/Identity.java 3 kB
- castorehcache/web/jsp/testEhcache.jsp 0.5 kB
- castorehcache/web/.../castor.properties 9 kB
- castorehcache/web/.../castor_config.xml 0.7 kB
- castorehcache/.../AbsCastorDataBase.class 4 kB
- castorehcache/web/.../CastorHelper.class 2 kB
- castorehcache/web/.../AbsMbookDataBase.class 0.8 kB
- castorehcache/web/.../base/UserBase.class 2 kB
- castorehcache/web/.../TestHelper.class 4 kB
- castorehcache/web/.../classes/ehcache.xml 15 kB
Activity
I'd suggest to address the different issues mentioned in the readme individually. As such, I'll add a sub-task to make the Identity class implement java.io.Serializable first, and we'll take it from there, okay ?
Just looking at the ClassCastExceptions ... lines 278ff of SqlTypeConvertors defines the following convertor:
new Convertor(Integer.class, Boolean.class) {
public Object convert(final Object obj, final String pm) {
return new Boolean(((Integer) obj).intValue() != 0);
}
}
which happens to be converting Integrer instances to booleans. Any idea why you are being passed a String instance ?
And finally, I do have a theory (but not more) as to why you are seeing these exceptions. It looks like you are trying to do long transactions, correct ? With Castor JDO, this means that the entity in question has too implement the TimeStampable interface, and that a cache has to be used for these entities. Every time you load an entity that implements TimeStampable, the time stamp associated with this entity will be updated in the cache as well, to highlight the last access to this entity. This is necessary so that Castor JDO can detect if (e.g. another thread) has already changed this entity when you call Database.update() .. throwing a ObjectModifiedException as a result.
When you use EHCache as cache provider for this entity, EHCache will replicate the cache content in your cluster, and for entities that implement TimeStampable, this will include the timestamp as well.But that means that if you happen to load the same instance in two threads, and one changes (updates) this instance later, this entity's information (incl. the time stamp) will be replicated through-out your cluster. As a result, when the other thread tries to perform the update operation, you'll get the exception you are seeing.
Does this make any sense to you ?
Just going back to my own explanation from above. I'd personally consider this 'third' exception to be semantically correct. Just imagine you would not get that ObjectModifiedException: in that case you would risk overwriting values from another thread that happened to be 'updating' the entity in question earlier than you. I am still not a 100% sure about all this, but let me have a closer look at the load() operation for 'TimeStampable's.
Is it an option for you to get the latest sources from SVN, and build the JARs yourself ? If yes, you could in addition insert a new LOG statement at line 278 of that SqlTypesConvertor to see what it is that is causing the ClassCastException ? If not, I could ship a new snapshot release of 1.1.2, even though I do not really like the idea of adding debug statements on purpose to a release. Let me know your preferences.
I really wonder whether I managed to explain the OME to you in such a way that you realize that the behaviour you are seeing is 'expected behaviour' ?
Hello Werner,
Sorry I didnīt answer you... I have been moving things to production and I didnīt have time to work on this isue.
Any way... I understand de behaviour about the timestamp but that makes ehcache send information and look thinks all the time for read only operation.
I wander if there is a way of telling castor that a query is a read only. That way the timestamp is not important and the object doesnīt change making ehcache send the modified object throught the network.
In my case, the application is mostlly read only but with a lot of users doing queries, this makes a lot of unecesary network trafic between application instances for ehcache...
I will try to find time and work on this...
Regards,
Gonzalo Abollado.
Before trying to answer your question(s), let me just ask you one question first: if your domain object in question is read-only, how come you are using the Database.update() call at all ? It just does not make sense to me. If a domain object is read-only, it implies that it will never change during its life-time. That means that never ever anybody should have to use long transactions for such domain objects. Looks like I am getting something completely wrong.
Just to make sure, you managed to resolve this by making the Identity class implement java.io.Serializable, correct ?