title: NoClassDefFoundError: org/w3c/dom/ls/DocumentLS - issue occurring only on deployment after having fixed it on compile time
body: <h2>Background</h2>
  
  <p>I have a project where I parse some XML documents and I happened to need the <code>xerces</code> dependency: </p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;xerces&lt;/groupId&gt;
      &lt;artifactId&gt;xerces&lt;/artifactId&gt;
      &lt;version&gt;2.4.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>While writing the unit tests with <code>junit4</code>, I had an issue every time I was running a unit test, which was the following and occurring every time I was compiling with <code>mvn clean install</code>:</p>
  
  <pre><code>[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.346 s &lt;&lt;&lt; FAILURE! - in ConversionTest
  [ERROR] ConversionTest.initializationError  Time elapsed: 0.054 s  &lt;&lt;&lt; ERROR!
  java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
          at ConversionTest.fromDirectory(ConversionTest.java:92)
          at ConversionTest.data(ConversionTest.java:65)
  Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ls.DocumentLS
          at ConversionTest.fromDirectory(ConversionTest.java:92)
          at ConversionTest.data(ConversionTest.java:65)
  </code></pre>
  
  <h2>Compile-time solution</h2>
  
  <p>Searching the web, I have realized that I needed to add a new dependency to my <code>pom.xml</code>: </p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;xerces&lt;/groupId&gt;
      &lt;artifactId&gt;xercesImpl&lt;/artifactId&gt;
      &lt;version&gt;2.11.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>After doing this, the tests compiled fine and I could produce my <code>.jar</code> which was packaged with the following build plug-in:</p>
  
  <pre><code>        &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.4&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;com.company.tools.Application&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt; 
  </code></pre>
  
  <p>... and compiled with the following settings: </p>
  
  <pre><code>        &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;${maven.compiler.plugin.version}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;encoding&gt;cp1252&lt;/encoding&gt;
                  &lt;release&gt;11&lt;/release&gt;
                  &lt;fork&gt;true&lt;/fork&gt;
                  &lt;meminitial&gt;128m&lt;/meminitial&gt;
                  &lt;maxmem&gt;512m&lt;/maxmem&gt;
                  &lt;compilerArgs&gt;
                      &lt;arg&gt;-Xpkginfo:always&lt;/arg&gt;
                  &lt;/compilerArgs&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>This produced a <code>.jar</code> which contains all the required dependencies, here including the famous <code>org/w3c/dom/ls/DocumentLS</code>: </p>
  
  <p><a href="https://i.stack.imgur.com/Cpq0G.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Cpq0G.png" alt="enter image description here"></a></p>
  
  <h2>Deployment</h2>
  
  <p>Now I move this <code>.jar</code> into my server and try to run it with the following command: </p>
  
  <pre><code>java -jar myJar.jar &lt;inputs&gt;
  </code></pre>
  
  <p>When I do that, I get the following exception, again! </p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
          at java.base/java.lang.ClassLoader.defineClass1(Native Method)
          at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
          at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
          at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:801)
          at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:699)
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:622)
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
          at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
          at org.apache.xerces.jaxp.DocumentBuilderImpl.&lt;init&gt;(Unknown Source)
          at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
          at com.company.tools.impl.FileProviderImpl.getXmlFile(FileProviderImpl.java:68)
          at com.company.tools.impl.FileProviderImpl.&lt;init&gt;(FileProviderImpl.java:38)
          at com.company.tools.impl.FileProviderImpl$Builder.build(FileProviderImpl.java:91)
          at com.company.tools.Application.main(Application.java:50)
  Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ls.DocumentLS
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
          at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
          ... 15 more
  </code></pre>
  
  <h2>My question and some details about the machines</h2>
  
  <p>I am a bit lost here. I've added the dependency to my <code>pom.xml</code>, the class is well packaged inside the <code>.jar</code>, but still I have the same issue. 
  What am I doing wrong? </p>
  
  <p>If it can help: </p>
  
  <p><em>My machine</em>:</p>
  
  <pre><code>Java version: 11.0.2-BellSoft, vendor: BellSoft, runtime: C:\jdk-11.0.2
  Default locale: fr_FR, platform encoding: Cp1252
  OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
  </code></pre>
  
  <p><em>My server</em>:</p>
  
  <pre><code>openjdk version "11" 2018-09-25
  OpenJDK Runtime Environment 18.9 (build 11+28)
  OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)
  OS: Linux myServerAddress 3.10.0-327.el7.x86_64 #1 SMP Thu Oct 29 17:29:29 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
  </code></pre>
  
  <p>Thanks in advance!</p>