title: Unable to configure second level cache in hibernate 4.x
body: <p>I am using <code>hibernate 4.3</code> and <code>MySQL 5.0.</code>I am trying to configure a second level cache in my example as follows.</p>
  
  <p>My <code>hibernate.cfg.xml</code></p>
  
  <pre><code>&lt;property name="hibernate.cache.use_second_level_cache"&gt;true&lt;/property&gt;
  &lt;property name="hibernate.cache.region.factory_class"&gt;org.hibernate.cache.ehcache.EhCacheRegionFactory&lt;/property&gt;
  </code></pre>
  
  <p>My Entity class</p>
  
  <pre><code>@Entity
  @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
  @Cacheable
  public class Employee { ...}
  </code></pre>
  
  <p>I am getting following Exception</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/service/jndi/JndiNameException
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Unknown Source)
  at org.jboss.logging.Logger$1.run(Logger.java:2252)
  at java.security.AccessController.doPrivileged(Native Method)
  at org.jboss.logging.Logger.getMessageLogger(Logger.java:2227)
  at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
  at org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory.&lt;clinit&gt;(AbstractEhcacheRegionFactory.java:77)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Unknown Source)
  at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:242)
  at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:125)
  at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:87)
  at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:46)
  at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:83)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:223)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:197)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
  at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:295)
  at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2442)
  at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2438)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1855)
  at com.example.hibernate.Hibernate4Main.main(Hibernate4Main.java:33)
  Caused by: java.lang.ClassNotFoundException: org.hibernate.service.jndi.JndiNameException
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  ... 22 more
  </code></pre>
  
  <p>What is missing in my configuration? I know second level cache configuration in <code>hibernate 4.x</code> is different for <code>3.x</code>. I have searched that but not getting working answer for me.</p>
  
  <p><em>Thanks for help.</em></p>