Error deploying Primefaces application on JBoss 7.

2020-04-14 02:48发布

问题:

I am trying to deploy a JSF (Primefaces) application in JBOSS 7.1.0.

I am getting the following error:

18:17:03,390 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (MSC 
service thread 1-8) Critical error during deployment: :  
com.sun.faces.config.ConfigurationException:Factory  
'javax.faces.context.PartialViewContextFactory' was not configured properly.
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactories
Exist(FactoryConfigProcessor.java:305) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAP
SHOT]
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(Factory
ConfigProcessor.java:219) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:361)
[jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureLi
stener.java:225) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
    at org.apache.catalina.core.StandardContext.contextListenerStart(Standar
dContext.java:3392) [jbossweb-7.0.10.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
850) [jbossweb-7.0.10.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentS
ervice.java:90) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(Se
rviceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceCont
rollerImpl.java:1746)

Any ideas?

Thanks.

回答1:

This indicates that there's a conflict with another JSF implementation in the webapp's runtime classpath. Full fledged Java EE application servers like JBoss AS, Glassfish, WebSphere, Weblogic, etc already ship with JSF bundled since that's part of the Java EE API. If you supply JSF in your webapp's /WEB-INF/lib as well, it may conflict with the appserver-bundled JSF. The JSF API part will be loaded from the appserver-provided JSF libraries, but the JSF impl part will be loaded from the webapp-provided JSF libraries. If they are of a different version, then you'll get configuration errors like this.

You have 2 options:

  1. Remove the webapp-bundled JSF and rely on the server-bundled JSF.

  2. Tell the server to use webapp-bundled JSF instead. How to do that depends on the server make/version. In your particular case with JBoss 7.x, that would be a matter of adding the following context parameter to webapp's web.xml:

    <context-param>
        <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
        <param-value>true</param-value>
    </context-param> 
    

Barebones JSP/Servlet containers like Tomcat, Jetty, etc doesn't ship with JSF bundled, that's why you would need to provide your own JSF libraries in /WEB-INF/lib when targeting such containers.

See also:

  • JSF 2 Issues in Application Servers?