views:

814

answers:

2

When I include hibernate-c3p0 in my Maven's pom.xml file, I get a runtime NoClassDefFoundError as it can't find org.slf4j.impl.StaticLoggerBinder. It was my impression that Maven would resolve this dependency – so if c3p0 requires slf4j, then slf4j would be downloaded and included.

My pom.xml file has:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-c3p0</artifactId>
  <version>3.3.1.GA</version>
</dependency>
+3  A: 

It could be that slf4j is an optional dependency. You can check the transitive dependencies very easily using the dependency plugin

mvn dependency:tree

will show you a tree listing of exactly what depends on what. If slf4j is not a dep, you can add it explicity.

HTH

sgargan
+3  A: 

The NoClassDefFoundError for org.slf4j.impl.StaticLoggerBinder indicates that no SLF4J binding could be found. By transitivity, hibernate-c3p0 depends on slf4j-api. However, slf4j-api cannot function without a binding. See SLF4J user manual for details: www.slf4j.org/manual.html

You just need to add one of slf4j-simple, slf4j-log4j12, slf4j-jdk14, or logback-classic as a dependency. The SLF4J manual page mentioned earlier should have the details.

Ceki
or the famous slf4j-nop, it's pretty fast :)
Willi