ClassNotFoundException org slf4j impl StaticLoggerBinder
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder Exception in thread "main" java.lang.ExceptionInInitializerError at com.javahonk.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:14) at com.javahonk.util.HibernateUtil.<clinit>(HibernateUtil.java:7) at com.javahonk.OneToOneInsert.main(OneToOneInsert.java:16) Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255) at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:165) at com.javahonk.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:11) ... 2 more Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoou ader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 10 more
Solution: If you are getting above error it means slf4j-log4j12.jar is missing from your classpath. If you are using maven project please add below dependency in your pom.xml file
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.5.0</version> </dependency>
- If you are using eclipse project add slf4j-log4j12.jar in your class path.
It’s also possible that you need to use a newer version of maven, such as maven 3.0 instead of maven 2.2.