title: JBoss ClassLoading Parent-Last loading
body: <p>I wanted to understand <strong>parent-last</strong> loading in an application JBoss application server. We have a legacy application deployed in JBoss 4.2.1 GA. For which we are trying the parent-last loading.</p>
  
  <p>I am referring to the this <a href="https://developer.jboss.org/wiki/JBossClassLoadingUseCases" rel="nofollow noreferrer">link</a>.
  I wanted to learn a parent last loading. So had created simple maven jar package application with maven-jar-plugin and configuration -> addDefaultImplementationEntries = true. I have created 2 jar versions 1.0.0 and 1.0.1 from the same jar creation maven application. The jar has single class TestClass and a simple String return method that returns the version of the jar the class is loaded from.
  <strong>what I wanted to experience the use of java2ClassLoadingCompliance</strong>. I have packaged the version 1.0.0 jar in the server/deploy/MyApplication/WEB-INF/lib (My web application is a simple servlet application that calls the method of the class thus printing the version number from which jar it was called from.) and version 1.0.1 jar in server/lib. </p>
  
  <p><strong><em>Note</strong> : Logically it does not make sense to use an older version of jar in application and overriding it with the newer version present in server lib, but just wanted to experience the class loading.</em></p>
  
  <p>I have tried the following </p>
  
  <ol>
  <li>Without any jboss-web.xml in the meta-inf folder.</li>
  <li>I tried introduction jboss-we.xml in META-INF and doing the same with java2ClassLoadingCompliance = false.</li>
  <li>With java2ClassLoadingCompliance = true. </li>
  </ol>
  
  <p>All the time class from the application lib would get loaded by the application.</p>
  
  <p>My jboss-web.xml looks like <a href="https://developer.jboss.org/wiki/ClassLoadingConfiguration" rel="nofollow noreferrer">reference</a> </p>
  
  <pre><code>&lt;jboss-web&gt;
     &lt;class-loading java2ClassLoadingCompliance="true"&gt;
        &lt;loader-repository&gt;
           com.example:archive=JBossClassLoadingTestServlet-0.0.1-SNAPSHOT.ear
           &lt;loader-repository-config&gt;java2ParentDelegation=true&lt;/loader-repository-config&gt;
        &lt;/loader-repository&gt;
     &lt;/class-loading&gt;
  &lt;/jboss-web&gt;
  </code></pre>
  
  <p>Can someone help me understanding parent-last configuration in JBoss? What is the mistake I am doing here that always class from application lib gets loaded?</p>