-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: slf4j not loading StaticLoggerBinder even with slf4j-log4j
PostPosted: Fri May 06, 2011 11:24 am 
Newbie

Joined: Fri May 06, 2011 10:54 am
Posts: 4
This is very interesting because I have look through many forums and THIS particular problem seems to be new:

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

Even with the all the proper jars (I’m using log4j so I have slf4j-api-1.5.8.jar and slf4j-log4j12-1.5.8.jar in my classpath). I’ve googled this to death, and tried a trick with switching to an older version of slf4j (1.5.2 to be precise). I even tried newer versions (hibernate 3.6 comes with slf4j-api 1.6 if I'm not mistaken). Same error. I’ve tried Hibernate 3.3.2 and 3.6 getting the same results. I included the log4j jar also and took it out (rolling dice at that point) with the same results.

I’ve looked in the slf4j-log4j12-1.5.8.jar and the class is there (just being sure), but it just isn’t getting loaded. Any answers???


Top
 Profile  
 
 Post subject: Re: slf4j not loading StaticLoggerBinder even with slf4j-log4j
PostPosted: Fri May 06, 2011 6:48 pm 
Newbie

Joined: Fri May 06, 2011 10:54 am
Posts: 4
Here's my code. VERY simple. "Hello World" simple.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="connection.url">jdbc:derby://localhost:1527/HibernateDb;create=true</property>
<property name="connection.username">blank</property>
<property name="connection.password">blank</property>
<property name="hibernate.default_schema">TESTSCHEMA</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">2</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>

<!-- Enable Hibernate's current session context -->
<!-- <property name="current_session_context_class">org.hibernate.context.ManagerSessionContext</property> -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup -->
<!-- <property name="hbm2ddl.auto">create</property> -->

<!-- Table mapping resources -->
<!-- <mapping resource="" /> -->

</session-factory>

</hibernate-configuration>








package com.rain.hibernateexpamples;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;



@Entity
@Table(name="Contacts")
public class Contact {

@Id
@GeneratedValue
private long contactId;

@Column(name="firstname", nullable=false)
private String firstName;

@Column(name="middleinitial")
private char middleInitial;

@Column(name="lastname", nullable=false)
private String lastName;

@Column(name="phonenumber")
private String phoneNumber;

@Column(name="emailaddress")
private String emailAddress;

public long getContactId() {
return contactId;
}
public void setContactId(long contactId) {
this.contactId = contactId;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public char getMiddleInitial() {
return middleInitial;
}
public void setMiddleInitial(char middleInitial) {
this.middleInitial = middleInitial;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
}







package com.rain.hibernateexpamples;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class TestContact {

/**
* @param args
*/
public static void main(String[] args) {
AnnotationConfiguration annotationConfig = new AnnotationConfiguration();
annotationConfig.addAnnotatedClass(Contact.class);
annotationConfig.configure("hibernate.cfg.xml");

// generate table from class
// CAUTION:
// Run this line once to generate table.
// If ran again, table data and/or structure will be lost.
new SchemaExport(annotationConfig).create(true, true);

// test object; YES I'M ROUTING FOR THE LAKERS
// transient for now
Contact contact = new Contact();
contact.setFirstName("Kobe");
contact.setMiddleInitial('J');
contact.setLastName("Bryant");
contact.setPhoneNumber("555-555-5555");
contact.setEmailAddress("kobe.bryant@hibernate.com");

/*
* .jar list
* antlr-2.7.6.jar
* commons-collections-3.1.jar
* dom4j-1.6.1.jar
* hibernate3.jar
* javassist-3.9.0.GA.jar
* jta-1.1.jar
* log4j-1.2.8.jar
* derbyclient.jar
* slf4j-api-1.5.8.jar
* slf4j-log4j12-1.5.8.jar
* jpa.jar
*/
}
}


Top
 Profile  
 
 Post subject: Re: slf4j not loading StaticLoggerBinder even with slf4j-log4j
PostPosted: Sun May 08, 2011 2:01 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
this works fine for the rest of the world, please check:
- the jar is really included in the classpath (you could double-check by having your code try to create some object from the jar directly)
- the jar is not corrupted
- use exactly the same versions of the hibernate version you're using

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: slf4j not loading StaticLoggerBinder even with slf4j-log4j
PostPosted: Mon May 09, 2011 10:14 pm 
Newbie

Joined: Fri May 06, 2011 10:54 am
Posts: 4
Thanks s.grinovero. With your suggestions (I created an object straight from the jar without a problem; so it's seeing the jars), you helped me think of a better idea ... with results to make me even more perplexed.

I HAVE to be the only person with this problem. The follow code is the sample code from http://www.slf4j.org/manual.html. This produces the same exact same error I am experiencing with my hibernate code. Both jars accounted for. Not sure if this is part of my problem but I'm using:
Eclipse Galileo
Java 1.6
slf4j 1.6.1

package com.rain.slf4j;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Slf4jExample {
public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(Slf4jExample.class);
logger.info("Hello World");
}
}



ERROR:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" 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 com.rain.slf4j.Slf4jExample.main(Slf4jExample.java:13)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
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 sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 7 more


Top
 Profile  
 
 Post subject: Re: slf4j not loading StaticLoggerBinder even with slf4j-log4j
PostPosted: Tue May 10, 2011 1:30 am 
Newbie

Joined: Fri May 06, 2011 10:54 am
Posts: 4
I've FINALLY gotten past this!!!

I got on another machine (with Eclipse Helios installed) and tried the "Hello World" example from the Slf4j site. Worked without issue. As far as why, I HAVEN'T A CLUE AND IT'S 1:30AM!!!!

Possible issues I'll look into:
Eclipse Galileo
Mac OS Snow Leopard


Top
 Profile  
 
 Post subject: Re: slf4j not loading StaticLoggerBinder even with slf4j-log4j
PostPosted: Tue May 10, 2011 3:27 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
maybe you have corrupted slf4j jars: try deleting them and downloading again?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.