title: What are the Maven dependencies to use hibernate, hibernate annotations, and ehcache?
body: <p>I would like to update my Maven pom.xml with the latest hibernate, hibernate-annotations, and ehcache dependencies.</p>
  
  <p>I read the hibernate download page and the ehcache donwload page. All my tries at interpreting it seem to fail. Can someone write out the snippet that should go into pom.xml?</p>
  
  <p>Cryptic hibernate download page:
  <a href="http://hibernate.org/downloads" rel="nofollow noreferrer">http://hibernate.org/downloads</a></p>
  
  <p>Cryptic ehcache download page:
  <a href="http://www.terracotta.org/dl/ehcache-oss-download-catalog" rel="nofollow noreferrer">http://www.terracotta.org/dl/ehcache-oss-download-catalog</a></p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>   &lt;properties&gt;
         &lt;hibernate.version&gt;3.6.0.Final&lt;/hibernate.version&gt;
     &lt;/properties&gt;
     &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
                  &lt;artifactId&gt;jta&lt;/artifactId&gt;
              &lt;/exclusion&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;net.sf.ehcache&lt;/groupId&gt;
                  &lt;artifactId&gt;ehcache&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-ehcache&lt;/artifactId&gt;
          &lt;version&gt;${hibernate.version}&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;net.sf.ehcache&lt;/groupId&gt;
                  &lt;artifactId&gt;ehcache&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;net.sf.ehcache&lt;/groupId&gt;
          &lt;artifactId&gt;ehcache&lt;/artifactId&gt;
          &lt;version&gt;2.2.0&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
      &lt;/dependency&gt;
   &lt;/dependencies&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;codehaus-repository&lt;/id&gt;
              &lt;name&gt;Codehaus&lt;/name&gt;
              &lt;url&gt;https://nexus.codehaus.org/content/repositories/releases/&lt;/url&gt;
              &lt;layout&gt;default&lt;/layout&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;java.net&lt;/id&gt;
              &lt;url&gt;http://download.java.net/maven/1&lt;/url&gt;
              &lt;layout&gt;legacy&lt;/layout&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;central&lt;/id&gt;
              &lt;name&gt;Maven Repository Switchboard&lt;/name&gt;
              &lt;layout&gt;default&lt;/layout&gt;
              &lt;url&gt;http://repo1.maven.org/maven2&lt;/url&gt;
              &lt;snapshots&gt;
                  &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;/snapshots&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;sonatype-ehcache&lt;/id&gt;
              &lt;url&gt;http://oss.sonatype.org/content/repositories/sourceforge-releases&lt;/url&gt;
              &lt;layout&gt;default&lt;/layout&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;JBoss Repository&lt;/id&gt;
              &lt;url&gt;https://repository.jboss.org/nexus/content/groups/public&lt;/url&gt;
              &lt;layout&gt;default&lt;/layout&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  </code></pre>
  
  <p>I know, it looks like a big mess, because I don't seem to figure out, where all the dependencies are stored.</p>
  
  <p>The above fails with:</p>
  
  <pre><code>Invocation of init method failed; nested exception is java.lang.NullPointerException
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
  </code></pre>
  
  <p>Update:
  Pascal, your reply is very clear and well explained. However, hibernate still fails on startup.</p>
  
  <ol>
  <li><p>sl4j threw errors, which went away by adding:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
      &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
      &lt;version&gt;1.6.1&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre></li>
  <li><p>There are many instances of this warning:</p>
  
  <pre><code>g in the two-phase commit!
  1797 [main] WARN  net.sf.ehcache.hibernate.AbstractEhcacheRegionFactory  - No Tr
  ansactionManagerLookup found in Hibernate config, XA Caches will be participatin
  </code></pre></li>
  <li><p>Additionally, this error makes everything fail:</p>
  
  <p>Related cause:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean wit
  h name 'financialDAO' defined in ServletContext resource [/WEB-INF/config/applic
  ationContext-database.xml]: Cannot resolve reference to bean 'transactionManager
  ' while setting bean property 'transactionManager'; nested exception is org.spri
  ngframework.beans.factory.BeanCreationException: Error creating bean with name '
  transactionManager' defined in ServletContext resource [/WEB-INF/config/applicat
  ionContext-database.xml]: Cannot resolve reference to bean 'sessionFactory' whil
  e setting bean property 'sessionFactory'; nested exception is org.springframewor
  k.beans.factory.BeanCreationException: Error creating bean with name 'sessionFac
  tory' defined in ServletContext resource [/WEB-INF/config/applicationContext-dat
  abase.xml]: Invocation of init method failed; nested exception is java.lang.Null
  PointerException
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver
  .resolveReference(BeanDefinitionValueResolver.java:328)
  </code></pre></li>
  </ol>
  
  <p>To confirm, this is the spring configuration:</p>
  
  <pre><code>&lt;!-- Enable EHCache --&gt;
  &lt;prop key="hibernate.cache.use_second_level_cache"&gt;true&lt;/prop&gt;
  &lt;prop key="hibernate.cache.use_query_cache"&gt;false&lt;/prop&gt;
  &lt;prop key="hibernate.cache.region.factory_class"&gt;net.sf.ehcache.hibernate.EhCacheRegionFactory&lt;/prop&gt;
  &lt;prop key="net.sf.ehcache.configurationResourceName"&gt;/ehcache.xml&lt;/prop&gt;
  </code></pre>
  
  <p>Update:
  This seems to be the latest exception that hibernate gets stuck on:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
      at net.sf.ehcache.hibernate.HibernateUtil.loadAndCorrectConfiguration(HibernateUtil.java:48)
      at net.sf.ehcache.hibernate.EhCacheRegionFactory.start(EhCacheRegionFactory.java:79)
      at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:236)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:855)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:774)
      at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
  </code></pre>