Erro ao conectar banco com Hibernate/Java eclipse

2 respostas
eclipseexceptionerrorhibernatejava
Alexsandro_Andrade

bom dia, estou tentando realizar uma conexão com banco através do hibernate no entanto ao compilar o código é apresentada a seguinte exceção.

Failed to instantiate SLF4J LoggerFactory

Reported exception:

java.lang.NoClassDefFoundError: org/apache/log4j/Level

at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)

at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)

at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)

at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)

at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)

at org.hibernate.cfg.Configuration.(Configuration.java:197)

at org.hibernate.ejb.Ejb3Configuration.(Ejb3Configuration.java:133)

at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)

at projetoteste.TestHibernate.main(TestHibernate.java:12)

Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

 11 more

Exception in thread main java.lang.NoClassDefFoundError: org/apache/log4j/Level

at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)

at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)

at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)

at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)

at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)

at org.hibernate.cfg.Configuration.(Configuration.java:197)

at org.hibernate.ejb.Ejb3Configuration.(Ejb3Configuration.java:133)

at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)

at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)

at projetoteste.TestHibernate.main(TestHibernate.java:12)

Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

 11 more

2 Respostas

M

Tenta adicionar o Log4j nas dependências do projeto.

https://mvnrepository.com/artifact/log4j/log4j

Alexsandro_Andrade

Matheus, como você pode ver, os arquivos .jar referente a SLF4J estão devidamente inclusos no classpath.

Criado 1 de novembro de 2017
Ultima resposta 1 de nov. de 2017
Respostas 2
Participantes 2