jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • castor
  • CASTOR-1969

Tomcat castor and Ehcache distributed environment

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major 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.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Hide
    Zip Archive
    castorehcache.zip
    08/May/07 1:29 PM
    3.52 MB
    Gonzalo Abollado
    1. XML File
      castorehcache/build.xml 2 kB
    2. File
      castorehcache/castorehcache.iml 3 kB
    3. File
      castorehcache/castorehcache.ipr 16 kB
    4. File
      castorehcache/castorehcache.iws 36 kB
    5. File
      castorehcache/etc/castor.properties 9 kB
    6. XML File
      castorehcache/etc/castor_config.xml 0.7 kB
    7. XML File
      castorehcache/etc/ehcache.xml 15 kB
    8. XML File
      castorehcache/etc/ehcache.xsd 4 kB
    9. File
      castorehcache/etc/log4j.properties 1 kB
    10. XML File
      castorehcache/etc/mapping/User.xml 0.8 kB
    11. XML File
      castorehcache/etc/mapping.xml 0.1 kB
    12. XML File
      castorehcache/etc/web.xml 0.5 kB
    13. File
      castorehcache/mysql.sql 2 kB
    14. Text File
      castorehcache/README.txt 22 kB
    15. Java Source File
      castorehcache/src/.../AbsCastorDataBase.java 5 kB
    16. Java Source File
      castorehcache/src/.../CastorHelper.java 2 kB
    17. Java Source File
      castorehcache/src/.../AbsMbookDataBase.java 0.6 kB
    18. Java Source File
      castorehcache/src/com/.../base/UserBase.java 1 kB
    19. Java Source File
      castorehcache/src/.../TestHelper.java 2 kB
    20. Java Source File
      castorehcache/src/.../EHCache.java 13 kB
    21. Java Source File
      castorehcache/src/org/.../spi/Identity.java 3 kB
    22. File
      castorehcache/web/jsp/testEhcache.jsp 0.5 kB
    23. File
      castorehcache/web/.../castor.properties 9 kB
    24. XML File
      castorehcache/web/.../castor_config.xml 0.7 kB
    25. File
      castorehcache/.../AbsCastorDataBase.class 4 kB
    26. File
      castorehcache/web/.../CastorHelper.class 2 kB
    27. File
      castorehcache/web/.../AbsMbookDataBase.class 0.8 kB
    28. File
      castorehcache/web/.../base/UserBase.class 2 kB
    29. File
      castorehcache/web/.../TestHelper.class 4 kB
    30. XML File
      castorehcache/web/.../classes/ehcache.xml 15 kB
    Showing 30 of 56 items Download Zip
    Show
    Zip Archive
    castorehcache.zip
    08/May/07 1:29 PM
    3.52 MB
    Gonzalo Abollado
  • Options
    • Show All
    • Show Open

Sub-Tasks

1.
Make org.exolab.castor.persist.spi.Identity implement java.io.Serializable Sub-task Closed Closed Werner Guttmann

0%

Original Estimate - 20 minutes
Remaining Estimate - 20 minutes
 

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Werner Guttmann added a comment - 09/May/07 2:29 AM

Just to make sure, you managed to resolve this by making the Identity class implement java.io.Serializable, correct ?

Show
Werner Guttmann added a comment - 09/May/07 2:29 AM Just to make sure, you managed to resolve this by making the Identity class implement java.io.Serializable, correct ?
Hide
Permalink
Werner Guttmann added a comment - 09/May/07 2:35 AM

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 ?

Show
Werner Guttmann added a comment - 09/May/07 2:35 AM 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 ?
Hide
Permalink
Werner Guttmann added a comment - 09/May/07 3:07 AM

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 ?

Show
Werner Guttmann added a comment - 09/May/07 3:07 AM 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 ?
Hide
Permalink
Werner Guttmann added a comment - 09/May/07 3:13 AM

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 ?

Show
Werner Guttmann added a comment - 09/May/07 3:13 AM 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 ?
Hide
Permalink
Werner Guttmann added a comment - 09/May/07 3:26 AM

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.

Show
Werner Guttmann added a comment - 09/May/07 3:26 AM 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.
Hide
Permalink
Werner Guttmann added a comment - 09/May/07 4:48 AM

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.

Show
Werner Guttmann added a comment - 09/May/07 4:48 AM 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.
Hide
Permalink
Werner Guttmann added a comment - 15/May/07 2:35 AM

Gonzalo ?

Show
Werner Guttmann added a comment - 15/May/07 2:35 AM Gonzalo ?
Hide
Permalink
Werner Guttmann added a comment - 15/May/07 2:53 AM

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' ?

Show
Werner Guttmann added a comment - 15/May/07 2:53 AM 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' ?
Hide
Permalink
Gonzalo Abollado added a comment - 18/May/07 5:37 AM

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.

Show
Gonzalo Abollado added a comment - 18/May/07 5:37 AM 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.
Hide
Permalink
Werner Guttmann added a comment - 20/May/07 3:28 PM

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.

Show
Werner Guttmann added a comment - 20/May/07 3:28 PM 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.

People

  • Assignee:
    Werner Guttmann
    Reporter:
    Gonzalo Abollado
Vote (0)
Watch (0)

Dates

  • Created:
    08/May/07 1:29 PM
    Updated:
    20/May/07 3:28 PM

Time Tracking

Estimated:
20m
Original Estimate - 20 minutes
Remaining:
20m
Remaining Estimate - 20 minutes
Logged:
Not Specified
Time Spent - Not Specified

Not Specified

  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.