V4forums Weblog

Stay Hungry, Stay Foolish

SLF4J Vs JCL / Dynamic Binding Vs Static Binding

leave a comment »

This morning I downloaded latest version of Hibernate and was trying to use it for one of my web application that I was working on.
As I configured all the mapping details of the relevent entities and pointed hibernate to MySQL to create the schema, I ended up with the following error:

java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:128)
… 46 more

What I understood was Hibernate recently introduced the use of the Simple Logging Facade for Java (slf4j) whose jar files are actually missing from my classpath. It was easy to fix the problem by adding the respective jars on my classpath and get going.

But on the other side I was bit curious to know more about SLF4J. So without much hesitation I started digging into the details with http://www.sl4j.org as the primary point of my dwelling. The following are some of the interesting facts that I learnt. As you would see I would be mostly refering to the external links on the facts, my goal is to make this blog complete.

Simply put, SLF4J is a simple facade for logging systems allowing the end-user to plug-in the desired logging system at deployment time.You can consider it asĀ  a counter part of Jakarta Commons Logging (JCL).With so much complains regarding the dynamic binding approach taken by JCL, SLF4J has taken the simple approach of static binding which would eventually solve all the dynamic class loading problems while using JCL.

Dyanamic Binding Vs Static Binding

* So what exactly is this Dyanamic and Static binding in Java all about?

The answer is very clearly explained in the following link. Thanks for the at most simplicity approach taken to explain the differences between Dynamic and Static binding.

http://geekexplains.blogspot.com/2008/06/dynamic-binding-vs-static-binding-in.html

Problems with JCL

* So what kind of problems does the JCL pose on developers because of dynamic binding/class loading?

The answer can be found much more in detail through the following blog.

http://wrschneider.blogspot.com/2005/06/commons-logging-classloader-pain_18.html

SLF4J using static binding approach (LESS IS MORE!)

How does SLF4J help us to get rid of the problems using static binding approach? I think the following snap-shot taken from SL4J manual says a thousand words than any further explanation (same picture can be found in the SL4J Manual).

slf4j

Just a final information. Looks like not only Hibernate, but all the JBosses are making a move towards SLF4J.

More useful information on SLF4J can be found here:

http://www.slf4j.org/faq.html
http://www.slf4j.org/manual.html
http://www.slf4j.org/docs.html

About these ads

Written by v4forums

December 27, 2008 at 8:41 am

Posted in Java

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: