title: Weblogic 10.3.5: <prefer-web-inf-classes> in weblogic.xml not working VS. server classpath JAR files
body: <p><strong>Weblogic version</strong>: 10.3.5</p>
  
  <p><strong>JSF version (interfaces, impl) :</strong> Mojarra 2.0.3</p>
  
  <p>I have a JSF <code>EAR</code> application which is made up of a <code>WAR</code> file and a <code>JAR</code> file.</p>
  
  <p>The <code>WAR</code> file contains the following two <code>Maven</code> dependencies:</p>
  
  <pre><code> &lt;dependency&gt;
          &lt;groupId&gt;javax.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
          &lt;version&gt;2.0.3&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
          &lt;version&gt;2.0.3&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>When running, the following code snippet <strong>correctly</strong> reports the current in-service version of <code>Mojarra</code> as v2.0.3:</p>
  
  <pre><code>public void getMojarraVersion() {
      Package p = FacesContext.class.getPackage();
      System.out.println("Mojarra version: " + p.getImplementationTitle() + " " + p.getImplementationVersion());
  }
  </code></pre>
  
  <p>The weblogic startup log, however reports that a different, far older version provided by the container, is used when the application is started:</p>
  
  <pre><code>INFO: Initializing Sun's JavaServer Faces implementation (1.2_03-b04-FCS) for context '/myApp'
  </code></pre>
  
  <p>This is despite the following <code>weblogic.xml</code> configuration, deployed alongside the <code>WAR</code> file's <code>web.xml</code> file in <code>WEB-INF</code>, which inverts the classloader:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd"&gt;
       &lt;wls:container-descriptor&gt;
          &lt;wls:prefer-web-inf-classes&gt;true&lt;/wls:prefer-web-inf-classes&gt;
       &lt;/wls:container-descriptor&gt;
  &lt;/wls:weblogic-web-app&gt;
  </code></pre>
  
  <p>After a couple of days of digging, I discovered the following two JAR Files are being included in the server classpath:</p>
  
  <pre><code>${WEBLOGIC_HOME}/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/jsf-api.jar
  
  ${WEBLOGIC_HOME}/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/jsf-impl.jar
  </code></pre>
  
  <p>These files are provided by a vanilla install of <code>Weblogic</code> 10.3.5.</p>
  
  <p>Temporarily removing these two JAR files and restarting the server caused the log to start reporting that the new version is in use:</p>
  
  <pre><code>INFO: Initializing Mojarra 2.0.3 for context '/myApp'
  </code></pre>
  
  <p>The above evidence therefore demonstrates that Weblogic configuration to subvert the classloader hierarchy <strong>does not work</strong> for any resources that are provided by the server classpath (i.e. <code>${WEBLOGIC_HOME}/wlserver_10.3/server/lib</code>) when an application is loaded.</p>
  
  <p>As an interesting aside, I can delete the <code>weblogic.xml</code> file and I find that:</p>
  
  <ol>
  <li>The wrong version of the dependency continues to be reported in the startup log.</li>
  <li>The correct version of the dependency continues to be used at runtime.</li>
  </ol>