Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Spring Modules Cache + Hibernate 2nd-level cache Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Modules Cache + Hibernate 2nd-level cache

    Hi guys,

    We've been using Spring Modules to cache some JDBC DAOs for a while now with great success. Now we are slowly starting to migrate some DAOs to use JPA/Hibernate instead and we'd like to cache some of those too. For this we figured that using the Hibernate second-level cache would be appropriate and so we tried configuring it. Unfortunately we now end up with an EHCache (our cache provider) exception which looks like that:

    Code:
    net.sf.ehcache.CacheException: Cannot parseConfiguration CacheManager. Attempt to create a new instance of CacheManager using the diskStorePath "C:\DOCUME~1\RU9211~1\LOCALS~1\Temp\" which is already used by an existing CacheManager. The source of the configuration was classpath.
    I guess this exception is natural, since two different libraries are trying to use and configure EHCache as their cache provider: Hibernate and Spring Modules. My question is: how can we adapt our current setup so that both these libraries can use EHCache?

    Our persistence.xml:

    Code:
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    	version="1.0">
    
    	<persistence-unit name="promoPersistenceUnit"
    		transaction-type="RESOURCE_LOCAL">
    		<provider>org.hibernate.ejb.HibernatePersistence</provider>
    		<class>model.stores.Store</class>
    		<properties>
    			<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect" />
                <property name="hibernate.cache.use_second_level_cache" value="true" />
    			<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
            </properties>
    	</persistence-unit>
    </persistence>
    and part of our applicationContext.xml:

    Code:
    	<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" />
    	<bean id="cacheProvider" class="org.springmodules.cache.provider.ehcache.EhCacheFacade">
    		<property name="cacheManager" ref="cacheManager" />
        </bean>
    Thanks a lot!
Working...
X