Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

Tags:

java

slf4j

tiles

I'm trying to run the sample tiles example given here.

Below is my POM.xml:

<dependencies>         <dependency>             <groupId>junit</groupId>             <artifactId>junit</artifactId>             <version>3.8.1</version>             <scope>test</scope>         </dependency>         <dependency>             <groupId>org.apache.tiles</groupId>             <artifactId>tiles-api</artifactId>             <version>2.1.2</version>         </dependency>         <dependency>             <groupId>org.apache.tiles</groupId>             <artifactId>tiles-core</artifactId>             <version>2.1.2</version>         </dependency>         <dependency>             <groupId>org.apache.tiles</groupId>             <artifactId>tiles-jsp</artifactId>             <version>2.1.2</version>         </dependency>         <dependency>             <groupId>org.slf4j</groupId>             <artifactId>slf4j-api</artifactId>             <version>1.5.2</version>         </dependency> 

When I'm trying to run the example the below error is thrown:

Sep 17, 2010 11:59:43 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Error configuring application listener of class      org.apache.tiles.web.startup.TilesListener java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685) at org.apache.tiles.web.startup.TilesListener.<init>(TilesListener.java:49) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) 

Any idea?

I spent 30 minutes googling for this but could not find a possible sollution.

Please help me...

like image 803
javanoob Avatar asked Sep 17 '10 18:09

javanoob


People also ask

How do you fix No class Def Found error?

lang. NoClassDefFoundError, which means the Class Loader file responsible for dynamically loading classes can not find the . class file. So to remove this error, you should set your classpath to the location where your Class Loader is present.

What is Exception in thread main Java Lang NoClassDefFoundError?

NoClassDefFoundError is a common error in Java that occurs if a ClassLoader cannot find a particular class in the classpath while trying to load it. The Exception in thread "main" suggests that this error has occurred in the main thread, the thread which is responsible for running the Java application.


2 Answers

You have included a dependency on the SLF4J API, which is what you use in your application for logging, but you must also include an implementation that does the real logging work.

For example to log through Log4J you would add this dependency:

    <dependency>         <groupId>org.slf4j</groupId>         <artifactId>slf4j-log4j12</artifactId>         <version>1.5.2</version>     </dependency> 

The recommended implementation would be logback-classic, which is the successor of Log4j, made by the same guys that made SLF4J and Log4J:

<dependency>     <groupId>ch.qos.logback</groupId>     <artifactId>logback-classic</artifactId>     <version>0.9.24</version> </dependency> 

Note: The versions may be incorrect.

like image 118
gpeche Avatar answered Sep 23 '22 07:09

gpeche


You have included the dependency for sflj's api, but not the dependency for the implementation of the api, that is a separate jar, you could try slf4j-simple-1.6.1.jar.

like image 45
Nathan Hughes Avatar answered Sep 21 '22 07:09

Nathan Hughes