title: Spring boot runnable jar can't find classloader set via java.system.class.loader jvm parameter
body: <p>In a module structure like this:</p>
  <p>project<br />
  |<br />
  |- common module<br />
  |- app module</p>
  <p>Where app module has common module as a dependency, I have a custom classloader class defined in the common module. The app module has a <code>-Djava.system.class.loader=org.project.common.CustomClassLoader</code> jvm parameter set to use that custom classloader defined in common module.</p>
  <p>Running a spring boot project within IDEA this works perfectly. The custom classloader is found, set as a system classloader and everything works.</p>
  <p>Compiling a runnable jar (using default spring-boot-maven-plugin without any custom properties), the jar itself has all the classes and within it's lib directory is the common jar which has the custom classloader. However running the jar with the <code>-Djava.system.class.loader=org.project.common.CustomClassLoader</code> results in the following exception</p>
  <pre><code>java.lang.Error: org.project.common.CustomClassLoader
      at java.lang.ClassLoader.initSystemClassLoader(java.base@12.0.2/ClassLoader.java:1989)
      at java.lang.System.initPhase3(java.base@12.0.2/System.java:2132)
  Caused by: java.lang.ClassNotFoundException: org.project.common.CustomClassLoader
      at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@12.0.2/BuiltinClassLoader.java:583)
      at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@12.0.2/ClassLoaders.java:178)
      at java.lang.ClassLoader.loadClass(java.base@12.0.2/ClassLoader.java:521)
      at java.lang.Class.forName0(java.base@12.0.2/Native Method)
      at java.lang.Class.forName(java.base@12.0.2/Class.java:415)
      at java.lang.ClassLoader.initSystemClassLoader(java.base@12.0.2/ClassLoader.java:1975)
      at java.lang.System.initPhase3(java.base@12.0.2/System.java:2132)
  
  </code></pre>
  <p>Why does this happen? Is it because in the runnable jar the classloader class is in a jar in lib directory so the classloader is trying to get set before the lib classes were added to the classpath? Is there anything I can do besides moving the classloader from common to all the other modules that need it?</p>
  <p><strong>EDIT</strong>: I've tried moving the custom classloader class from common module to app but I am still getting the same error. What is going on here?</p>