title: ehcache hibernate 4
body: <p>In my application I use the hibernate-core-4.1.8 jar and would like to take an ehCache as 2nd level cache. 
  The jar I am currently using is ehcache-core-2.5.0. I placed it in my WebContetn/WEB-INF/lib folder and put it in the classpath too.</p>
  
  <p>My hibernate.cfg.xml looks like this:</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
      &lt;session-factory&gt;   
      ....    
          &lt;property name="hibernate.cache.region.factory_class"&gt;org.hibernate.cache.ehcache.EhCacheRegionFactory&lt;/property&gt;
          &lt;property name="hibernate.cache.use_second_level_cache"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.cache.use_query_cache"&gt;true&lt;/property&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>the ehcache.xml which is placed in the JavaResources/src folder:</p>
  
  <pre><code>&lt;ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
          monitoring="autodetect" dynamicConfig="true"&gt;
  
      &lt;defaultCache
                  maxElementsInMemory="100000"
                  eternal="false"
                  timeToIdleSeconds="1000"
                  timeToLiveSeconds="1000"
                  overflowToDisk="false"
                  /&gt;
  &lt;/ehcache&gt;
  </code></pre>
  
  <p>When running my application the class org.hibernate.cache.ehcache.EhCacheRegionFactory is not found:</p>
  
  <pre><code>java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.cache.ehcache.EhCacheRegionFactory
      at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:264)
      at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
      at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:444)
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:275)
      at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2283)
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2279)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1748)
      at creator.controllers.MyFactory.&lt;clinit&gt;(MyFactory.java:18)
      at creator.controllers.SchoolDAO.getList(SchoolDAO.java:98)
      .....
  </code></pre>