title: slf4j LoggerFactory class definition not found with Gradle
body: <p>I'm trying to build and run a Spark webserver that uses slf4j logging in IntelliJ. It builds fine (also in IntelliJ) on the computer that was used to originally add logging, but not on my machine.</p>
  
  <p>Here's the full <code>build.gradle</code> file (see <code>project(':webserver')</code> for the part that uses the logger:</p>
  
  <pre><code>buildscript {
      repositories {
          maven {
              url "https://plugins.gradle.org/m2/"
          }
      }
      dependencies {
          classpath "gradle.plugin.com.avast.gradle:docker-compose-gradle-plugin:0.3.27"
      }
  }
  
  subprojects {
      repositories {
          mavenLocal()
          mavenCentral()
          jcenter()
      }
  
      apply plugin: "java"
      apply plugin: "idea"
      apply plugin: "checkstyle"
      apply plugin: "pmd"
      apply plugin: "findbugs"
      apply plugin: "application"
      apply plugin: "com.avast.gradle.docker-compose"
  
      checkstyle {
          configFile = "../config/checkstyle/checkstyle.xml" as File
          toolVersion = "6.0"
      }
  }
  
  project(':webserver') {
      mainClassName = "org.passport.webserver.WebServer"
      dependencies {
          compile project(':core')
          compile "com.sparkjava:spark-core:2.6.0"
          testCompile 'junit:junit:4.12'
          compile group: 'org.json', name: 'json', version: '20090211'
          compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.1'
      }
  
      sourceSets {
          main {
              java {
                  srcDir 'src/main/java/'
              }
          }
      }
  }
  
  project(':customsUI') {
      mainClassName = "org.passport.customsui.CustomsUI"
      dependencies {
          compile project(':core')
          testCompile 'junit:junit:4.12'
      }
  
      sourceSets {
          main {
              java {
                  srcDir 'src/main/java/'
              }
          }
      }
  }
  
  project(':handlerUI') {
      mainClassName = "org.passport.handlerui.HandlerUI"
      dependencies {
          compile project(':core')
          testCompile 'junit:junit:4.12'
      }
  
      sourceSets {
          main {
              java {
                  srcDir 'src/main/java/'
              }
          }
      }
  }
  
  project(':core') {
      mainClassName = "org.passport.core.PassPortChaincode"
      dependencies {
          compile 'io.grpc:grpc-all:0.13.2'
          compile 'commons-cli:commons-cli:1.3.1'
          compile 'org.glassfish:javax.json:1.1.0-M1'
          compile files('lib/shim-client-1.0.jar')
          testCompile 'junit:junit:4.12'
      }
  
      sourceSets {
          main {
              java {
                  srcDir 'src/main/java/'
              }
          }
      }
  }
  </code></pre>
  
  <p>Here's the code that uses the logger:</p>
  
  <pre><code>package org.passport.webserver;
  
  import org.passport.webserver.endpoints.ContainerClaimDao;
  import org.passport.webserver.endpoints.PackageClaimDao;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  import static spark.Spark.before;
  import static spark.Spark.get;
  import static spark.Spark.path;
  import static spark.Spark.post;
  
  /**
   * The server matches requests (routs) and calls the appropriate endpoints.
   */
  public final class Server {
  
      private static Logger logger = LoggerFactory.getLogger(Server.class);
      private static ContainerClaimDao containers = new ContainerClaimDao();
      private static PackageClaimDao packages = new PackageClaimDao();
  
      private Server() {
  
      }
  
      /**
       * Starts the router.
       * @param args run arguments
       */
      public static void main(String[] args) {
          path("/containers/:container-id", () -&gt; {
              before("/*", (q, a) -&gt; logger.info("Received api call: " + q.url() + "."));
  
              post("", (request, response) -&gt; containers.add(request, response));
  
              get("/container-claims", (request, response) -&gt; containers.get(request, response));
  
              get("/package-claims", (request, response) -&gt;   packages.get(request, response));
  
          });
      }
  
  }
  </code></pre>
  
  <p>And here's the error I get:</p>
  
  <pre><code>"C:\Program Files\Java\jdk1.8.0_91\bin\java" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.2.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_91\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_91\jre\lib\rt.jar;C:\Users\lover\repositories\passport\webserver\build\classes\main;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.2.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.passport.webserver.Server
  Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
      at org.passport.webserver.Server.&lt;clinit&gt;(Server.java:18)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:264)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:123)
  Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 4 more
  </code></pre>
  
  <p>I've looked at several questions on StackOverflow, but none seem to solve the problem:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/12926899/java-lang-noclassdeffounderror-org-slf4j-loggerfactory">java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory</a> - I'm building with gradle, don't think I should have to download/ put some jar in my classpath</li>
  <li><a href="https://stackoverflow.com/questions/9030065/classnotfoundexception-org-slf4j-loggerfactory">ClassNotFoundException: org.slf4j.LoggerFactory</a> - Same as above</li>
  <li><a href="https://stackoverflow.com/questions/26458806/noclassdeffounderror-org-slf4j-logger">NoClassDefFoundError: org/slf4j/Logger</a> - Again jar stuff</li>
  <li><a href="https://stackoverflow.com/questions/36377461/caused-by-java-lang-classnotfoundexception-org-slf4j-loggerfactory">Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory</a> - I'm not sure whether "fat jars" / ShadowJar apply, and not sure how to modify my build file to use them</li>
  <li><a href="https://stackoverflow.com/questions/39747780/noclassdeffounderror-org-slf4j-loggerfactory-while-creating-a-runnable-jar-wi">NoClassDefFoundError: org/slf4j/LoggerFactory while creating a runnable *.jar with gradle</a> - I've tried refreshing gradle several times, restarting IntelliJ, and even restarting my restarting my computer</li>
  <li><a href="https://stackoverflow.com/questions/42531127/gradle-exception-in-thread-main-java-lang-noclassdeffounderror-org-slf4j-logg">Gradle Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory</a> - See below</li>
  </ul>
  
  <p>I've tried the following dependencies:</p>
  
  <ul>
  <li><code>compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.1'</code></li>
  <li><code>compile 'org.slf4j:slf4j-api:1.7.24'</code> and <code>compile 'org.slf4j:slf4j-simple:1.7.24'</code></li>
  <li><code>compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1'</code></li>
  </ul>
  
  <p>None of this seems to make a difference. Any ideas?</p>