1 Reply Latest reply on Apr 5, 2010 4:19 PM by chris.simons

    Hibernate JPA never finds my ehcache2.xml

      I have been struggling with something simple - having our Seam app (Hibernate/JPA/EJB) find our custom ehcache2.xml file.  I have made sure that the config file is everywhere it could possibly be - in the EAR's lib, in the JAR, in the WAR/WEB-INF/ - in probably eight different places in order to make sure it can be picked up.  To no avail, I always see this when I deploy:



      09:44:08,218 WARN  [ConfigurationFactory] No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: zip:C:/bea11g
      /user_projects/domains/HIDDEN/lib/ehcache-1.5.0.jar!/ehcache-failsafe.xml





      I have caching enabled in many places with great success - but I want to take it farther and define my own regions and how EhCache should handle them.  Here is the relevant snippet from persistence.xml:




      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
              <property name="hibernate.show_sql" value="false"/>
              <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider"/>
              <!--<property name="hibernate.cache.region.factory_class" value=" net.sf.ehcache.hibernate.EhCacheRegionFactory"/>-->
              <property name="hibernate.cache.provider_configuration_file_resource_path" value="ehcache2.xml"/>
              <!--<property name="cache.provider_configuration_file_resource_path" value="/ehcache2.xml"/>-->
              <property name="hibernate.cache.use_query_cache" value="true"/>
              <property name="hibernate.use_second_level_cache" value="true"/>
              <property name="hibernate.default_batch_fetch_size" value="16"/>
              <property name="hibernate.generate_statistics" value="true"/>



        • 1. Re: Hibernate JPA never finds my ehcache2.xml

          Looks like I just figured it out - I was using an old property name/value pair for ehcache.xml configuration path.


          I changed it to:


                  <property name="net.sf.ehcache.configurationResourceName" value="/ehcache2.xml"/>


          But then I began to receive NoClassDefFound errors on backport-util-concurrent.jar - funny that this would only now become an issue.


          To resolve this issue, I made sure backport-util-concurrent.jar was added to my EAR/lib.


          Next, I changed the cacheproviderclass to the Singleton.




                  <!--<property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider"/>-->
                  <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider"/>   
                  <!--<property name="hibernate.cache.region.factory_class" value=" net.sf.ehcache.hibernate.EhCacheRegionFactory"/>-->
                  <property name="net.sf.ehcache.configurationResourceName" value="/ehcache2.xml"/>