This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Best practices for Hibernate/Spring/Caching config

Jul 17th, 2007, 07:29 AM

I am using Hibernate for the first time on a Spring web app and am looking for some best practice guidance on how to configure the caching. I'm planning to use ehcache, and found the org.springframework.cache.ehcache.EhCacheManagerFa ctoryBean in the Spring API.

I found this post and implemented it. However, it appears from the logs that two separate caches are being created:

Code:

08:13:34,782 INFO [/dc]:647 - Initializing Spring root WebApplicationContext
08:13:34,844 INFO RuntimeEnvironmentXmlWebApplicationContext:378 - Refreshing edu.bju.shared.util.spring.RuntimeEnvironmentXmlWebApplicationContext@10ab323: display name [Root WebApplicationContext]; startup date [Tue Jul 17 08:13:34 EDT 2007]; root of context hierarchy
08:13:35,673 INFO RuntimeEnvironmentXmlWebApplicationContext:393 - Bean factory for application context
08:13:39,627 WARN CacheManager:292 - Creating a new instance of CacheManager using the diskStorePath "C:\DOCUME~1\Sschaub1\LOCALS~1\Temp\" which is already used by an existing CacheManager.
The source of the configuration was classpath.
The diskStore path for this CacheManager will be set to C:\DOCUME~1\Sschaub1\LOCALS~1\Temp\\ehcache_auto_created_1184674419627.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
08:13:40,425 WARN EhCacheProvider:36 - Could not find configuration [edu.bju.shared.model.people.PersonWareHouse]; using defaults.
08:13:40,440 DEBUG EhCacheProvider:39 - started EHCache region: edu.bju.shared.model.people.PersonWareHouse
08:13:40,690 WARN EhCacheProvider:36 - Could not find configuration [edu.bju.shared.model.people.PersonWareHouseLite]; using defaults.
08:13:40,690 DEBUG EhCacheProvider:39 - started EHCache region: edu.bju.shared.model.people.PersonWareHouseLite
08:13:41,128 WARN EhCacheProvider:36 - Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
08:13:41,128 DEBUG EhCacheProvider:39 - started EHCache region: org.hibernate.cache.UpdateTimestampsCache
08:13:41,128 WARN EhCacheProvider:36 - Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.
08:13:41,144 DEBUG EhCacheProvider:39 - started EHCache region: org.hibernate.cache.StandardQueryCache
08:13:41,878 WARN CacheManager:292 - Creating a new instance of CacheManager using the diskStorePath "C:\DOCUME~1\Sschaub1\LOCALS~1\Temp\" which is already used by an existing CacheManager.
The source of the configuration was classpath.
The diskStore path for this CacheManager will be set to C:\DOCUME~1\Sschaub1\LOCALS~1\Temp\\ehcache_auto_created_1184674421878.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.

I think I want a single cache that is shared by both the servlet and application contexts, correct? I would appreciate some advice.