HERE1
HERE2
Initial SessionFactory creation failed.java.lang.NoSuchFieldError:
name
Exception in thread "main" java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:18)
at events.EventManager.createAndStoreEvent(EventManager.java:50)
at events.EventManager.main(EventManager.java:18)
Caused by: java.lang.NoSuchFieldError: name
at org.slf4j.impl.Log4jLoggerAdapter.<init>(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.<clinit>(Configuration.java:151)
at util.HibernateUtil.<clinit>(HibernateUtil.java:14)
... 2 more
Hibernate.java:
package util;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new
Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be
swallowed
System.err.println("Initial SessionFactory creation
failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
EventManager.java:
package events;
import org.hibernate.Session;
import java.util.List;
import java.util.Date;
import util.HibernateUtil;
public class EventManager {
public static void main(String[] args) {
EventManager mgr = new EventManager();
System.out.println("HERE1");
if (args[0].equals("store")) {
System.out.println("HERE2");
mgr.createAndStoreEvent("My Event", new Date());
System.out.println("HERE3");
}
}
I am running this code in Eclipse and was originally thinking it was a
problem with the log4j.properties file, but I can't figure out what
the problem is.
Your help is appreciated.
Bill
I have the save problem...
I was having the same problem and I solved it by downloading an older
version of slf4j.
the version of slf4j-api shipped with hibernate is 1.5.2 (lib/common/
slf4j-1.5.2.jar)
I downloaded the same version of slf4j from here: http://www.slf4j.org/dist/
and the problem is gone.
Regards,
Christos
Thanks Christos,
J.
this solution stil doesn's work for me ...
I have :
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 util.HibernateUtil.<clinit>(HibernateUtil.java:18)
at annuaire.test.TestHibernate.main(TestHibernate.java:14)
Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/
StaticLoggerBinder
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 1 more
Julien
Hi,
i had the same problem,but i worked it out adding the "slf4j-
jdk14-1.5.2.jar" in the project's classpath. The missing class is
inside.
Regards,
Luis
Thanks,
works for me as well. thanks!