title: Second level cache in Hibernate 3.2.0 final
body: <p>I have been facing problem in using second level cache. following are the required source you need to find out what the problem is.</p>
  
  <p>hibernate.cfg.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p></p>
  
  
  
  <p></p>
  
  <pre><code>    &lt;!-- a SessionFactory instance --&gt;
      &lt;session-factory&gt;
  
              &lt;!-- User  / Password --&gt;
              &lt;property name="connection.username"&gt;root&lt;/property&gt;
              &lt;property name="connection.password"&gt;&lt;/property&gt;
  
              &lt;!-- Database / Dialect Settings --&gt;
              &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
              &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
              &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/hibernate_001&lt;/property&gt;   
              &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
              &lt;!-- Second Level Cache --&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;property name="hibernate.cache.region.factory_class"&gt;org.hibernate.cache.ehcache.EhCacheRegionFactory&lt;/property&gt;               
  
  
              &lt;!-- mapping files --&gt;
              &lt;mapping class="com.example.bean.Employee"/&gt;
      &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>Employee Persistance Class</p>
  
  <pre><code>    @Entity
  @Cacheable
  @Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
  @Table(name="employee")
  public class Employee {
      @GeneratedValue
      @Id
      @Column(name="id")
      private int id;
      @Column(name="first_name")
      private String firstName;
      @Column(name="last_name")
      private String lastName;
      @Column(name="email")
      private String email;
      @Column(name="registration_date")
      private String registrationDate;
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
      public String getFirstName() {
          return firstName;
      }
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
      public String getLastName() {
          return lastName;
      }
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
      public String getEmail() {
          return email;
      }
      public void setEmail(String email) {
          this.email = email;
      }
      public String getRegistrationDate() {
          return registrationDate;
      }
      public void setRegistrationDate(String registrationDate) {
          this.registrationDate = registrationDate;
      }
  }
  </code></pre>
  
  <p>stacktrace</p>
  
  <pre><code>log4j:WARN No appenders could be found for logger    (org.hibernate.cfg.annotations.Version).
  log4j:WARN Please initialize the log4j system properly.
  org.hibernate.HibernateException: could not instantiate RegionFactory   [org.hibernate.cache.ehcache.EhCacheRegionFactory]
  at          org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:402)
  at    org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:270)
  at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
  at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
  at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
  at com.example.dao.HibernateSessionFactory.getSessionFactory(HibernateSessionFactory.java:11)
  at com.example.control.Main.main(Main.java:12)
  Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.ehcache.EhCacheRegionFactory
  at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:190)
  at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
  at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:397)
  ... 7 more
  </code></pre>
  
  <p>Couldn't create session factory</p>