title: Ubuntu 12.04, Tomcat7, NetBeans 7 - getting java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;
body: <p>I have a Java EE project, which is working fine in one of our remote servers with tomcat container. Whenever we want to make some changes to our application, we do it on our local machine, then build it and copy the <code>ws.war</code> on the server in the root of the tomcat.</p>
  
  <p>I want to setup the local development environment where I can make the changes to the application. I have the project source files with me. I did following things:</p>
  
  <pre><code> 1. Install tomcat7 in my home directory and set up `CATALINA_HOME`
      environment variable in `.bashrc`
   2. Install oracle-java and setup JAVA_HOME in `.bashrc`
   3. Install Netbeans 7 and import the project in it.
   4. Since, the Netbeans came with `glassfish` as default server, I added
      a tomcat as the server with proper configuration.
   5. I try running the application (through Netbeans), and I receive the following error:
  
  Jun 04, 2013 2:39:58 AM org.apache.catalina.core.AprLifecycleListener init
    2 INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/        lib:/usr/lib
    3 Jun 04, 2013 2:39:59 AM org.apache.coyote.AbstractProtocol init
    4 INFO: Initializing ProtocolHandler ["http-bio-8080"]
    5 Jun 04, 2013 2:39:59 AM org.apache.coyote.AbstractProtocol init
    6 INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
    7 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.Catalina load
    8 INFO: Initialization processed in 1100 ms
    9 Jun 04, 2013 2:39:59 AM org.apache.catalina.core.StandardService startInternal
   10 INFO: Starting service Catalina
   11 Jun 04, 2013 2:39:59 AM org.apache.catalina.core.StandardEngine startInternal
   12 INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
   13 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.HostConfig deployDescriptor
   14 INFO: Deploying configuration descriptor /home/frrole/apache-tomcat-7.0.40/conf/Catalina/localhost/ws.xml
   15 Jun 04, 2013 2:39:59 AM org.apache.catalina.startup.HostConfig deployDescriptor
   16 WARNING: A docBase /home/frrole/apache-tomcat-7.0.40/webapps/projectfrrole/target/ws inside the host appBase has been specified, and will be ignored
   17 Jun 04, 2013 2:40:00 AM org.apache.catalina.core.ContainerBase addChildInternal
   18 SEVERE: ContainerBase.addChild: start:
   19 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ws]]
   20     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
   21     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
   22     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
   23     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
   24     at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
   25     at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636)
   26     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
   27     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
   28     at java.util.concurrent.FutureTask.run(FutureTask.java:166)
   29     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   30     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   31     at java.lang.Thread.run(Thread.java:722)
   32 Caused by: java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;
   33     at java.lang.Class.getDeclaredFields0(Native Method)
   34     at java.lang.Class.privateGetDeclaredFields(Class.java:2317)
   35     at java.lang.Class.getDeclaredFields(Class.java:1762)
   36     at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
   37     at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
   38     at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
   39     at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)
   40     at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
   41     at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
   42     at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
   43     at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
   44     at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
   45     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
   46     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   47     ... 11 more
   48 Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
   49     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
  </code></pre>
  
  <p>I did some research and I found out that there's some version incompatibility with 1.6.1 version and previous versions of <code>slf4j</code>. However, I'm not able to find a fix for this. </p>
  
  <p>Any help is appreciated. My POM.xml is as following:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.frrole.service&lt;/groupId&gt;
      &lt;artifactId&gt;ws&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;frrole web service&lt;/name&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;springframework-version&gt;3.0.5.RELEASE&lt;/springframework-version&gt;
      &lt;/properties&gt;
      &lt;build&gt;
          &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.5&lt;/source&gt;
                      &lt;target&gt;1.5&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.1.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;packagingExcludes&gt;
                          WEB-INF/lib/*spring*.jar,
                          WEB-INF/lib/*common*.jar,
                          WEB-INF/lib/*http*.jar,
                          WEB-INF/lib/*connector*.jar,
                          WEB-INF/lib/*json*.jar,
                          WEB-INF/lib/*jackson*.jar,
                          WEB-INF/lib/*aspect*.jar,
                          WEB-INF/lib/*aop*.jar,
                          WEB-INF/lib/*c3p*.jar,
                          WEB-INF/lib/*jta*.jar,
                          WEB-INF/lib/*4j*.jar
                      &lt;/packagingExcludes&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;1.6.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-lang&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!--
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
              &lt;version&gt;${springframework-version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          --&gt;
          &lt;!--&lt;dependency&gt;
              &lt;groupId&gt;mm.mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mm.mysql&lt;/artifactId&gt;
              &lt;version&gt;2.0.7&lt;/version&gt;
          &lt;/dependency&gt;--&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;${springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;${springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;${springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
              &lt;version&gt;${springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
              &lt;version&gt;${springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-taglibs&lt;/artifactId&gt;
              &lt;version&gt;${springframework-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.18&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-io&lt;/groupId&gt;
              &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
              &lt;version&gt;1.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.json&lt;/groupId&gt;
              &lt;artifactId&gt;json&lt;/artifactId&gt;
              &lt;version&gt;20090211&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
              &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
              &lt;version&gt;4.1.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
              &lt;version&gt;1.9.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt;
              &lt;artifactId&gt;quartz&lt;/artifactId&gt;
              &lt;version&gt;2.1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.twitter4j&lt;/groupId&gt;
              &lt;artifactId&gt;twitter4j-core&lt;/artifactId&gt;
              &lt;version&gt;3.0.3&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>