J'essaie d'utiliser hibernate 3.5.1 final dans une application swing Et voici les pots que j'utilise:
Lorsque j'essaie d'exécuter l'application, j'obtiens le message d'erreur suivant:
Failed to instantiate SLF4J LoggerFactory
Reported exception:
Java.lang.NoClassDefFoundError: org/Apache/log4j/Level
at org.slf4j.LoggerFactory.bind(LoggerFactory.Java:128)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.Java:108)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.Java:279)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.Java:252)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.Java:265)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.Java:165)
at org.hibernate.ejb.Ejb3Configuration.<clinit>(Ejb3Configuration.Java:127)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.Java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.Java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.Java:32)
at com.xeno.xecamp.desktopManagement.Main.main(Main.Java:16)
Caused by: Java.lang.ClassNotFoundException: org.Apache.log4j.Level
at Java.net.URLClassLoader$1.run(URLClassLoader.Java:202)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.net.URLClassLoader.findClass(URLClassLoader.Java:190)
at Java.lang.ClassLoader.loadClass(ClassLoader.Java:307)
at Sun.misc.Launcher$AppClassLoader.loadClass(Launcher.Java:301)
at Java.lang.ClassLoader.loadClass(ClassLoader.Java:248)
... 11 more
Exception in thread "main" Java.lang.NoClassDefFoundError: org/Apache/log4j/Level
at org.slf4j.LoggerFactory.bind(LoggerFactory.Java:128)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.Java:108)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.Java:279)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.Java:252)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.Java:265)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.Java:165)
at org.hibernate.ejb.Ejb3Configuration.<clinit>(Ejb3Configuration.Java:127)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.Java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.Java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.Java:32)
at com.xeno.xecamp.desktopManagement.Main.main(Main.Java:16)
Caused by: Java.lang.ClassNotFoundException: org.Apache.log4j.Level
at Java.net.URLClassLoader$1.run(URLClassLoader.Java:202)
at Java.security.AccessController.doPrivileged(Native Method)
at Java.net.URLClassLoader.findClass(URLClassLoader.Java:190)
at Java.lang.ClassLoader.loadClass(ClassLoader.Java:307)
at Sun.misc.Launcher$AppClassLoader.loadClass(Launcher.Java:301)
at Java.lang.ClassLoader.loadClass(ClassLoader.Java:248)
Vous devez également inclure le fichier JAR Log4J dans le chemin d'accès aux classes.
Notez que slf4j-log4j12-1.6.4.jar
est uniquement un adaptateur permettant d’utiliser Log4J via l’API SLF4J. Il ne contient pas l'implémentation réelle de Log4J.
Vous devez télécharger log4j et ajouter votre classpath.
Dans mon environnement, je viens d'ajouter les deux fichiers au chemin de classe. Et ça va bien.
slf4j-jdk14-1.7.25.jar
slf4j-api-1.7.25.jar