title: java.lang.NoClassDefFoundError: org/hibernate/cache/EntityRegion configuring EHCache
body: <p>I'm trying to add <code>ehcache</code> (v2.6.0) to my <code>Hibernate 4.1.5.SP1</code> project, but having some configuration issues.  Specifically, I'm getting a <code>java.lang.NoClassDefFoundError</code>: <code>org/hibernate/cache/EntityRegion</code> error when I try and build my <code>Hibernate</code> configuration with </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;net.sf.ehcache.hibernate.EhCacheRegionFactory&lt;/property&gt;
  </code></pre>
  
  <p>Here's my <em>Maven</em> dependencies ...</p>
  
  <pre><code>    &lt;hibernate.version&gt;4.1.5.SP1&lt;/hibernate.version&gt;
      &lt;hibernate.validator.version&gt;4.3.0.Final&lt;/hibernate.validator.version&gt;
      &lt;ehcacheVersion&gt;2.6.0&lt;/ehcacheVersion&gt;
      ...
      &lt;!-- Hibernate dependencies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;${hibernate.validator.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;${hibernate.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;net.sf.ehcache&lt;/groupId&gt;
          &lt;artifactId&gt;ehcache-core&lt;/artifactId&gt;
          &lt;version&gt;${ehcacheVersion}&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Here's the Java code I use to configure it ...</p>
  
  <pre><code>    Configuration config = new Configuration()
          .setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect")
          .setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver")
          .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:myprojectTestDb")
          .setProperty("hibernate.connection.username", "sa")
          .setProperty("hibernate.connection.password", "")
          .setProperty("hibernate.connection.pool_size", "1")
          .setProperty("hibernate.connection.autocommit", "true")
          .setProperty("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider")
          .setProperty("hibernate.hbm2ddl.auto", "create-drop")
          .setProperty("hibernate.show_sql", "true")
          .setProperty("hibernate.current_session_context_class", "thread")
          .setProperty("hibernate.cache.use_second_level_cache", "true")
          .setProperty("hibernate.cache.region.factory_class", "net.sf.ehcache.hibernate.EhCacheRegionFactory")
          .addAnnotatedClass(Organization.class)
          .addAnnotatedClass(State.class) 
          .addAnnotatedClass(Country.class)
          .addAnnotatedClass(Domain.class)
          .addAnnotatedClass(Community.class);
      final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
      sessionFactory = config.buildSessionFactory(serviceRegistry);
  </code></pre>
  
  <p>and here's the hideous error.  WHat configuration am I missing?</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/hibernate/cache/EntityRegion
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
      at java.lang.Class.getConstructor0(Unknown Source)
      at java.lang.Class.getConstructor(Unknown Source)
      at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:386)
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:251)
      at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)
      at org.mainco.subco.orgsclient.service.OrganizationServiceTest.setupOrgServiceTest(OrganizationServiceTest.java:56)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.EntityRegion
      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)
      ... 32 more
  </code></pre>