How to deploy a JSF 2.1 webapp in Oracle Weblogic 12.1?

╄→尐↘猪︶ㄣ 提交于 2019-12-21 16:58:08

问题


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

<javax.enterprise.resource.webcontainer.jsf.config> <BEA-000000> 
<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

I am using the Mojarra implementation Version 2.1.13 - here is the corresponding pom.xml entry:

<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-api</artifactId> 
  <version>2.1.13</version>
</dependency>
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-impl</artifactId>
  <version>2.1.13</version>
</dependency>

I added the following lines to the weblogic.xml to prevent the weblogic server from loading the shipped jsf implementation:

<container-descriptor>
    <prefer-web-inf-classes>false</prefer-web-inf-classes>
    <prefer-application-packages>
        <package-name>javax.faces.*</package-name>
        <package-name>com.sun.faces.*</package-name>
        <package-name>com.bea.faces.*</package-name>
    </prefer-application-packages>

    <prefer-application-resources>
        <resource-name>javax.faces.*</resource-name>
        <resource-name>com.sun.faces.*</resource-name>
        <resource-name>com.bea.faces.*</resource-name>
        <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
    </prefer-application-resources>
</container-descriptor>

The WeblogicFacesConfigResourceProvider is contained in the weblogic.jar.

So what's going wrong here? - Any hints?


Solution

Okay, I found the solution: you have to add the META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider to the prefer-application-resources-section in the weblogic.xml. This configuration works for me: false javax.faces. com.sun.faces. com.bea.faces.*

    <prefer-application-resources>
        <resource-name>javax.faces.*</resource-name>
        <resource-name>com.sun.faces.*</resource-name>
        <resource-name>com.bea.faces.*</resource-name>
        <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
        <resource-name>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</resource-name>
    </prefer-application-resources>
</container-descriptor>

回答1:


Adding the solution mentioned by oehmiche in his question as an answer.

Add the META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider to the prefer-application-resources-section in the weblogic.xml. This configuration works for me: false javax.faces. com.sun.faces. com.bea.faces.*

<prefer-application-resources>
    <resource-name>javax.faces.*</resource-name>
    <resource-name>com.sun.faces.*</resource-name>
    <resource-name>com.bea.faces.*</resource-name>
    <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
    <resource-name>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</resource-name>
</prefer-application-resources>




回答2:


An addition to oemiche's solution: On WebLogic 12c R2 (12.2) you have to override the jsf.js coming from WegLogic's glassfish.jar (JSF 2.2):
Put the following into prefer-application-resources after ...FacesConfigResourceProvider:

<resource-name>META-INF/resources/javax.faces/jsf.js</resource-name>

You have to add this to weblogic-application.xml if you deploy your application as an ear.



来源:https://stackoverflow.com/questions/12898076/how-to-deploy-a-jsf-2-1-webapp-in-oracle-weblogic-12-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!