title: ClassNotFoundException: org.apache.log4j.Logger
body: <p>I have an issue with maven. I wrote a java code which is running in my idea. Then i use mvn package in order to build a jar. Still no problems. But for somes reasons i don't understand when i try to execute the jar maven have created i have this error :</p>
  
  <pre><code> Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
      at infra.Main.main(Main.java:53)
  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
      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:425)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  </code></pre>
  
  <p>Can someone help a newbie like me? </p>
  
  <p>Here is the beginning of java code:</p>
  
  <pre><code>package infra;
  
  import org.apache.log4j.Logger;
  import org.json.simple.JSONArray;
  import org.json.simple.JSONObject;
  import org.json.simple.parser.JSONParser;
  
  import javax.net.ssl.HttpsURLConnection;
  import javax.net.ssl.SSLContext;
  import javax.net.ssl.TrustManager;
  import javax.net.ssl.X509TrustManager;
  import java.io.*;
  import java.net.InetSocketAddress;
  import java.net.Proxy;
  import java.net.URL;
  import java.security.GeneralSecurityException;
  import java.security.cert.X509Certificate;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.Scanner;
  
  public class Main {
  
      private static String companyName = "lolilol";
  
      private static String baseUrl = "https://" + companyName + ".inspirecloud.net";
  
      private static String loginApi =  "/api/publish/Users/Login";
  
      private static String loginUrl =  baseUrl + loginApi;
  
      private static String fetchBatchesApi = "/api/query/Messenger/ListBatchesQueryByUploadTime";
  
      private static String fetchBatchesUrl = baseUrl + fetchBatchesApi;
  
      private static String detailBatcheApi = "/api/query/Messenger/ReportQuery";
  
      private static String detailBatcheUrl = baseUrl + detailBatcheApi;
  
      private static Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.local.fr", 8080));
  
      private static int nbEssais = 4;
  
      private static String header = "nbClic;Email;Id;Name;Customer;CompanyName;LastUploadTime;Type;MessageType;EmailId;ToEmailAdr;SendindState;Delivered;DeliveryError;FirstView;LastView;ViewCount;Unsubscribe;ServiceUsed;CustomerId;UrlLandingPage;GMC1;GMC2;GMC3;GMC4;GMC5;\n";
  
       private static Logger logger = Logger.getLogger(Main.class);
  
      public static void main(String[] args) {
  
  
          logger.info("Début des logs");
  
          HttpsURLConnection loginCon = null;
          HttpsURLConnection fetchBatchCon = null;
          HttpsURLConnection detailBatchCon;
  
          FileOutputStream fos = null;
          Scanner ficIn = null;
  
          int retry;
  
          String email;
          String password;
          String type;
          String from;
          String to;
  
  
          String cookie = null;
          String lineIn;
          String[] params;
          ArrayList&lt;String&gt; messagesMail = new ArrayList&lt;String&gt;();
  
  
          // Create a trust manager that does not validate certificate chains
          TrustManager[] trustAllCerts = new TrustManager[] {
                  new X509TrustManager() {
                      public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                          return new X509Certificate[0];
                      }
                      public void checkClientTrusted(
                              java.security.cert.X509Certificate[] certs, String authType) {
                      }
                      public void checkServerTrusted(
                              java.security.cert.X509Certificate[] certs, String authType) {
                      }
                  }
          };
  
          try
          {
              SSLContext sc = SSLContext.getInstance("SSL");
  
              sc.init(null, trustAllCerts, new java.security.SecureRandom());
              HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
          } catch (GeneralSecurityException e) {
              logger.error("Problème sécurité");
          }
  </code></pre>
  
  <p>And then here is the POM.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &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;trackingGMC&lt;/groupId&gt;
  &lt;artifactId&gt;TrackingGMC&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;addDefaultImplementationEntries&gt;true&lt;/addDefaultImplementationEntries&gt;
                          &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                          &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt;
                          &lt;mainClass&gt;infra.Main&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.googlecode.json-simple&lt;/groupId&gt;
          &lt;artifactId&gt;json-simple&lt;/artifactId&gt;
          &lt;version&gt;1.1.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j&lt;/artifactId&gt;
          &lt;version&gt;1.2.17&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>If you need more informations be free to ask. Thanks all.</p>