catch32
catch32

Reputation: 18582

Hibernate - java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

I tried to run easy program with hibernate and HSQLDB.

I'm using log4j for this project with log4j.properties:

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %c{1}:%L - %m%n

# Root logger option
log4j.rootLogger=INFO, stdout

# Hibernate logging options (INFO only shows startup messages)
log4j.logger.org.hibernate=INFO

# Log JDBC bind parameter runtime arguments
log4j.logger.org.hibernate.type=INFO

and all is build with Ant, build file you can see here.

But when I run schemaexport target I caught next error:

BUILD FAILED
/home/nazar_art/workspace/Persistance/build.xml:64: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

schemaexport error

But I hasn't use slf4j why this caused?

here is my content of lib folder with all jars that It uses:

lib struckture

I couldn't figure out why does this happen?

Here is better project structure:

project struckture

EDIT:

I added slf4j-api-1.6.1.jar and slf4j-log4j12-1.6.1.jar but it throws:

BUILD FAILED /home/nazar_art/workspace/Persistance/build.xml:64: java.lang.NoClassDefFoundError: javax/persistence/EntityListeners

you can see here how it looks:

entity listeners

How to solve this trouble?

Upvotes: 0

Views: 12206

Answers (2)

Bimalesh Jha
Bimalesh Jha

Reputation: 1504

Hibernate internally uses SLF4J for logging. Read the setup instructions here: http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#tutorial-firstapp-setup You need to keep SLF4J jar on the build and runtime classpath.

Upvotes: 0

noone
noone

Reputation: 19776

Hibernate uses SLF4J internally to do its own logging. It is an abstraction layer on top of different logging implementations. Frameworks like using this facade because in this case you still stay independend from certain implementations. You can also make it work with log4j. Follow this tutorial to make it work together.

Upvotes: 1

Related Questions