title: Hibernate 3.4 with slf4j and log4j
body: <p>I'm attempting to upgrade from Hibernate 3.2 to 3.4, which apparently uses slf4j. Our project currently uses log4j. So my assumption is that I should be using the slf4j-log4j12 wrapped implementation.</p>
  
  <p>The Maven slf4j dependency is:</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.5.6&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>While the log4j dependency is:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;log4j&lt;/groupId&gt;
      &lt;artifactId&gt;log4j&lt;/artifactId&gt;
      &lt;version&gt;1.2.15&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Both slf4j-log4j12 and log4j reference the latest version (that I could find in the Maven repository). When I run my app, Hibernate fails in its logging:</p>
  
  <pre><code>java.lang.NoSuchFieldError: name
      at org.slf4j.impl.Log4jLoggerAdapter.&lt;init&gt;(Log4jLoggerAdapter.java:75)
      at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
      at org.hibernate.cfg.Configuration.&lt;clinit&gt;(Configuration.java:163)
      ...
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p><strong>Edit 1:</strong> If I remove the log4j dependency from my pom.xml I get the error:</p>
  
  <pre><code>java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory
      at org.slf4j.LoggerFactory.&lt;clinit&gt;(LoggerFactory.java:60)
      at org.hibernate.cfg.Configuration.&lt;clinit&gt;(Configuration.java:163)
      ...
  </code></pre>
  
  <p><strong>Edit 2:</strong> <a href="http://www.innis.ca/blog/?p=6" rel="noreferrer">This blog</a> claims the problem is caused by hibernate annotations shipping with the wrong version of slf4j-api.jar.</p>