title: How to deploy a JSF 2.1 webapp in Oracle Weblogic 12.1?
body: <p>I am trying to deploy a JSF 2.1 webapplication to a Weblogic 12.1 application server, but the deployment fails with the following exception</p>
  
  <pre><code>&lt;javax.enterprise.resource.webcontainer.jsf.config&gt; &lt;BEA-000000&gt; 
  &lt;Critical error during deployment:
   com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! 
      com.oracle.injection.integration.jsf.WeblogicFacesConfigResourceProvider
                       cannot be cast to com.sun.faces.spi.ConfigurationResourceProvider
      at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:377)
      at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:223)
      at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:582)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      Truncated. see log file for complete stacktrace
  </code></pre>
  
  <p>I am using the Mojarra implementation Version 2.1.13 - here is the corresponding <code>pom.xml</code> entry: </p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
    &lt;artifactId&gt;jsf-api&lt;/artifactId&gt; 
    &lt;version&gt;2.1.13&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.1.13&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I added the following lines to the <code>weblogic.xml</code> to prevent the weblogic server from loading the shipped jsf implementation:</p>
  
  <pre><code>&lt;container-descriptor&gt;
      &lt;prefer-web-inf-classes&gt;false&lt;/prefer-web-inf-classes&gt;
      &lt;prefer-application-packages&gt;
          &lt;package-name&gt;javax.faces.*&lt;/package-name&gt;
          &lt;package-name&gt;com.sun.faces.*&lt;/package-name&gt;
          &lt;package-name&gt;com.bea.faces.*&lt;/package-name&gt;
      &lt;/prefer-application-packages&gt;
  
      &lt;prefer-application-resources&gt;
          &lt;resource-name&gt;javax.faces.*&lt;/resource-name&gt;
          &lt;resource-name&gt;com.sun.faces.*&lt;/resource-name&gt;
          &lt;resource-name&gt;com.bea.faces.*&lt;/resource-name&gt;
          &lt;resource-name&gt;META-INF/services/javax.servlet.ServletContainerInitializer&lt;/resource-name&gt;
      &lt;/prefer-application-resources&gt;
  &lt;/container-descriptor&gt;
  </code></pre>
  
  <p>The <code>WeblogicFacesConfigResourceProvider</code> is contained in the <code>weblogic.jar</code>.</p>
  
  <p>So what's going wrong here? - Any hints?</p>
  
  <hr>
  
  <h2>Solution</h2>
  
  <p>Okay, I found the solution: you have to add the <code>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</code> to the <code>prefer-application-resources</code>-section in the <code>weblogic.xml</code>. This configuration works for me:
      
          false
          
              javax.faces.<em>
              com.sun.faces.</em>
              com.bea.faces.*
          </p>
  
  <pre><code>    &lt;prefer-application-resources&gt;
          &lt;resource-name&gt;javax.faces.*&lt;/resource-name&gt;
          &lt;resource-name&gt;com.sun.faces.*&lt;/resource-name&gt;
          &lt;resource-name&gt;com.bea.faces.*&lt;/resource-name&gt;
          &lt;resource-name&gt;META-INF/services/javax.servlet.ServletContainerInitializer&lt;/resource-name&gt;
          &lt;resource-name&gt;META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider&lt;/resource-name&gt;
      &lt;/prefer-application-resources&gt;
  &lt;/container-descriptor&gt;
  </code></pre>