class not found exception: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

2,749 views
Skip to first unread message

Asil

unread,
Jan 24, 2011, 5:30:39 AM1/24/11
to hector...@googlegroups.com
I am trying to connect to Cassandra using Hector(Version : hector-0.7.0-22) in a Netbeans web app project.
I have created a servlet where I am trying to connect to Cassandra. I have included the path of jars from the hector zip file to the project's library. The build is successful, however when I try to run the project, it gives the following class not found exception:-
exception :  java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

I think hector might need to download some dependencies further, but I have never used maven and do not know how I can resolve this issue through maven. Can someone here show me the direction ?

I have already installed maven 3.0.2 to my computer but I do not know how I can use that in my Netbeans project to resolve this problem.
Also my hector version contains no pom.xml. It only contains some 15 jars. Version : hector-0.7.0-22

Thanks

Stephen Connolly

unread,
Jan 24, 2011, 6:25:58 AM1/24/11
to hector...@googlegroups.com

I think you need to read up a bit on how slf4j works.

Libraries which use slf4j should only expose a dependency on the
slf4j-api. This is what hector (at least with some of my pom
tidy-up... not sure about the exact version) should now be doing.

The net result is that you, as a consumer, do not have a slf4j
implementation on your classpath... this is good as the library
producer does not know what logging framework you want to use.

To solve this issue you need to add a dependency to one of the slf4j
implementations... "which one?" I hear you ask... that depends on what
logging provider you are using. The two most common ones are the
log4j and the java utils providers (slf4j-log4j and slf4j-jdk14
respectively)... "which version?" you now chime in... well it needs to
be at least the version used by hector, and if you are using a newer
version you will have to add a dependency to your project on the
corresponding version of slf4j-api in order to ensure that the
transitive resolution picks the same version of the api as the impl.

-Stephen

Aklin_81

unread,
Jan 24, 2011, 7:06:55 AM1/24/11
to hector...@googlegroups.com
Thanks so much Stephen !

Great answer!

Asil

Reply all
Reply to author
Forward
0 new messages