title: Maven build failing after adding classpath and dependencies in lib folder in pom.xml NoClassDefFoundError
body: <p>I have an app I built in Java and successfully compiled in Maven. After building I go to the target folder and run <code>java -jar *projectfilename*.jar</code> and I get the following error:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoClassDefFoundError:
    org/jibble/pircbot/PircBot
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
            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)
            at io.github.bholagabbar.Main.setupIRCBot(Main.java:9)
            at io.github.bholagabbar.Main.main(Main.java:27) Caused by: java.lang.ClassNotFoundException: org.jibble.pircbot.PircBot
            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)</p>
  </blockquote>
  
  <p>Now <code>org/jibble/pircbot/PircBot</code> which was not found is actually one of my dependencies in my pom.xml.</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/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;io.github.pixrat&lt;/groupId&gt;
    &lt;artifactId&gt;gallurdo&lt;/artifactId&gt;
    &lt;version&gt;1.0&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
  
    &lt;name&gt;gallurdo&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;id&gt;copy&lt;/id&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;copy-dependencies&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                &lt;outputDirectory&gt;
                  ${project.build.directory}/lib
                &lt;/outputDirectory&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.3.2&lt;/version&gt;
          &lt;configuration&gt;
            &lt;archive&gt;
              &lt;manifest&gt;
                &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt;
                &lt;mainClass&gt;io.github.pixrat.Main&lt;/mainClass&gt;
              &lt;/manifest&gt;
            &lt;/archive&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  
    &lt;repositories&gt;
      &lt;repository&gt;
        &lt;id&gt;jitpack.io&lt;/id&gt;
        &lt;url&gt;https://jitpack.io&lt;/url&gt;
      &lt;/repository&gt;
    &lt;/repositories&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;pircbot&lt;/groupId&gt;
        &lt;artifactId&gt;pircbot&lt;/artifactId&gt;
        &lt;version&gt;1.5.0&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.github.Ullink&lt;/groupId&gt;
        &lt;artifactId&gt;simple-slack-api&lt;/artifactId&gt;
        &lt;version&gt;0.5.1&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I have referred to answer here <a href="https://stackoverflow.com/questions/5797860/maven-noclassdeffounderror-in-the-main-thread">Maven: NoClassDefFoundError in the main thread</a>, <a href="https://stackoverflow.com/questions/5797860/maven-noclassdeffounderror-in-the-main-thread">Maven: NoClassDefFoundError in the main thread</a> and many other places but in vain. I'd appreciate some help thanks</p>