how to rectify "java.lang.NoClassDefFoundError" while using log4j in our class? <p>I have downloaded "apache-log4j-2.0-beta9-bin" from <a href="http://logging.apache.org/log4j/" rel="nofollow">http://logging.apache.org/log4j/</a> and extaracted it and added to my project. Then I wrote a configuration properties file in my project as below</p> <pre><code># Define the root logger with appender file log = X:\logs log4j.rootLogger = DEBUG, FILE # Define the file appender log4j.appender.FILE=org.apache.log4j.FileAppender log4j.appender.FILE.File=${log}/log.out # Define the layout for file appender log4j.appender.FILE.layout=org.apache.log4j.PatternLayout log4j.appender.FILE.layout.conversionPattern=%m%n </code></pre> <p>and I wrote sample program to test it, the sample program is shown below.</p> <pre><code>public class Log4jExample { static Logger log = Logger.getLogger(Log4jExample.class.getName()); public static void main(String[] args)throws IOException{ log.debug("Hello this is an debug message"); log.info("Hello this is an info message"); } } </code></pre> <p>While executing it am receiving this error, please advice.</p> <pre><code>java.lang.NoClassDefFoundError: org/apache/flume/Event at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:186) at org.apache.logging.log4j.core.config.plugins.PluginManager.decode(PluginManager.java:241) at org.apache.logging.log4j.core.config.plugins.PluginManager.collectPlugins(PluginManager.java:152) at org.apache.logging.log4j.core.config.plugins.PluginManager.collectPlugins(PluginManager.java:130) at org.apache.logging.log4j.core.pattern.PatternParser.&lt;init&gt;(PatternParser.java:116) at org.apache.logging.log4j.core.pattern.PatternParser.&lt;init&gt;(PatternParser.java:102) at org.apache.logging.log4j.core.layout.PatternLayout.createPatternParser(PatternLayout.java:183) at org.apache.logging.log4j.core.layout.PatternLayout.&lt;init&gt;(PatternLayout.java:115) at org.apache.logging.log4j.core.layout.PatternLayout.createLayout(PatternLayout.java:219) at org.apache.logging.log4j.core.config.DefaultConfiguration.&lt;init&gt;(DefaultConfiguration.java:51) at org.apache.logging.log4j.core.LoggerContext.&lt;init&gt;(LoggerContext.java:63) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:217) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:114) at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:81) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:83) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34) at org.apache.logging.log4j.LogManager.getContext(LogManager.java:200) at org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:61) at org.apache.log4j.Logger.getLogger(Logger.java:39) at log4j.Log4jExample.&lt;clinit&gt;(Log4jExample.java:16) Caused by: java.lang.ClassNotFoundException: org.apache.flume.Event at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 21 more </code></pre> <p>Exception in thread "main" Java Result: 1</p>