-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Please help with Hibernate caching in Tomcat!
PostPosted: Sun May 02, 2010 4:45 am 
Newbie

Joined: Sun May 02, 2010 4:30 am
Posts: 1
Hi everyone:

I seek help for a Tomcat web-based app I'm currently building. My web app that needs to update data quite frequently (about as much as it needs to read it), and I've been running into some stale data issues, all of which point to lack of synchronization between the Hibernate caches between Tomcat threads. Since HTTP requests to Tomcat are handled by a semi-randomly chosen Tomcat thread, I'm getting patterns such as these:

Call 1: Thread 5 - Data is good, update
Call 2: Thread 5- Data is good, update
Call 3: Thread 5 - Data is good, update
Call 4: Thread 7 - Data is stale, returns error :(
Call 5: Thread 7 - Data is stale, returns error :(
Call 6: Thread 5 - Data is good, update
Call 7: Thread 5 - Data is good, update
Call 8: Thread 7 - Data is stale, returns error :(
Call 9: Thread 7 - Data is good, update (I guess that here the cache expired and it refreshed its data from the database)
Call 10: Thread 7 - Data is good, update
Call 11: Thread 5 - Data is stale, returns error :(
...
...

So my best guess so far is that the caches are not being updated between threads. I've been playing around (unsuccessfully) with hibernate.cfg.xml and with ehcache.xml, trying to switch between NoCacheProvider, org.hibernate.cache.EhCacheProvider, its net.sf.ehcache version, SingletonEhCacheProvider, and others, to no avail. In desperation, I've tried to reduce the number of available threads to 1, and it hasn't worked either.

So I ask you - please help me... how do I configure my Hibernate+Tomcat app so that the cache is correctly replicated/invalidated between threads? I've worked with Hibernate for over a year before, but I had never had to build my application from scratch (until now), so I know fairly little about its configuration or caching details. All I need to do is keep my data consistent across Tomcat threads.

Thanks for reading this... and thank you more if you help me solve my problem! :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.