http://ehcache.sourceforge.net/documentation/hibernate.html

Are you setting this one?:

hibernate.cache.provider_configuration_file_resource_path=/name_of_configuration_resource

The error might be caused by a missing configuration item.

R.

On 1/30/07, Ding, Qin <[EMAIL PROTECTED]> wrote:

 From hibernate site, I found I need to change this line

from

<prop key="cache.provider_class">org.hibernate.cache.EhCacheProvider</prop
>

To

 <prop key=" hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider</prop>



However, it still does not work. I got the different error:

Invocation of init method failed; nested exception is
org.hibernate.HibernateException: could not instantiate CacheProvider:
org.hibernate.cache.EHCacheProvider

Caused by:

org.hibernate.HibernateException: could not instantiate CacheProvider:
org.hibernate.cache.EHCacheProvider

                at org.hibernate.cfg.SettingsFactory.createCacheProvider(
SettingsFactory.java:361)

                at org.hibernate.cfg.SettingsFactory.buildSettings(
SettingsFactory.java:232)

                at org.hibernate.cfg.Configuration.buildSettings(
Configuration.java:1933)

                at org.hibernate.cfg.Configuration.buildSessionFactory(
Configuration.java:1216)

                at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory





Qin
 ------------------------------

*From:* Ding, Qin [mailto:[EMAIL PROTECTED]
*Sent:* Tuesday, January 30, 2007 8:45 AM
*To:* [email protected]
*Subject:* RE: [appfuse-user] Turn on Ehcache in Appfuse



Mike: How do you turn the "second_level_cache" on?  I've added that to the
applicationConext-hibernate.xml, but still got the same error.



<property name="hibernateProperties">

                    <props>

                           <prop key="hibernate.dialect">
@HIBERNATE-DIALECT@</prop>

                           <prop key="hibernate.query.substitutions">true
'Y', false 'N'</prop>



                           <prop key="
hibernate.cache.use_second_level_cache">true</prop>

                           <prop key="cache.provider_class">
org.hibernate.cache.EhCacheProvider</prop>

                           <prop key="hibernate.generate_statistics">true
</prop>



                    </props>

</property>



Qin


  ------------------------------

*From:* Michael Horwitz [mailto:[EMAIL PROTECTED]
*Sent:* Monday, January 29, 2007 9:12 AM
*To:* [email protected]
*Subject:* Re: [appfuse-user] Turn on Ehcache in Appfuse



You need to set the hibernate property
hibernate.cache.use_second_level_cache to true, and if you want to use
query caches you need to set hibernate.cache.use_query_cache true as well.
Note that for the query cache you will need to enable caching on a query by
query basis.



Mike.





On 1/29/07, *Ding, Qin* <[EMAIL PROTECTED]> wrote:

I try to use ehcache in my appfuse 1.9.4 application.

In applicatonContext-hibernate.xml, <property name="hibernateProperties">

I added following:

<property name="hibernateProperties">

  <props>

    <prop key="hibernate.dialect">@HIBERNATE-DIALECT@</prop>

    <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>



    <prop key="cache.provider_class">org.hibernate.cache.EhCacheProvider
</prop>

<prop key="hibernate.generate_statistics">true</prop>

  </props>

</property>



In Status pojo, I added this xdoclet attribute:

[EMAIL PROTECTED] table="status"

[EMAIL PROTECTED] usage="read-write"



In ehcache.xml, besides the defaultCache, I added

<cache

      name="com.mycompany.model.Status"

      maxElementsInMemory="10"

      eternal="false"

      timeToIdleSeconds="0"

      timeToLiveSeconds="0"

      overflowToDisk="true" />



Then I compile and deploy to tomcat, the application failed to start with
very long error stack trace msg.  It seems caused by:



Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level
cache is not enabled for usage [hibernate.cache.use_second_level_cache |
hibernate.cache.use_query_cache ]

      at org.hibernate.cache.NoCacheProvider.buildCache(
NoCacheProvider.java:21)

      at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java
:61)

      ... 142 more



My question:  besides what I have done, what else should I add in order to
enable second-level cache?



Reply via email to