java.lang.IllegalArgumentException: javax.faces.lifecycle.ClientWindowFactory

我的未来我决定 提交于 2019-11-28 11:48:27

The webapp's runtime classpath is a mess.

Get rid of those JARs in /WEB-INF/lib

  • javaee-web-api-7.0.jar
  • javax.faces-2.2.5.jar
  • javax.servlet-api-3.0.1.jar

The first one is intented to be used to compile a WAR/EAR targeting a Java EE 7 container. It isn't intented to be installed along a WAR targeting a barebones JSP/Servlet container like Tomcat. It would get confused and think that it's actually a Java EE 7 container (oh joy).

The second one is Mojarra 2.2.5 (API and impl bundled in single-JAR flavor) and the cause of the initial trouble you're seeing. You're basically loading a JSF 2.2 implementation against a JSF 2.1 API already earlier loaded via Tomcat's /lib. The javax.faces.lifecycle.ClientWindowFactory is new since JSF 2.2 (see also @since in javadoc) and not recognized by JSF 2.1 API.

The third one is supposed to be already provided by Tomcat itself. Note that Java EE 7 JAR also contains JSF 2.2 and Servlet 3.1 APIs. So that's after all actually a triple conflict for JSF and Servlet APIs (one API from Tomcat's /lib, one API from WAR's /WEB-INF/lib, and one API from Java EE 7 JAR bundle; that's not good).

Regardless, I recommend to clean up Tomcat's /lib as well and keep it as default. Just stick to JARs in WAR's /WEB-INF/lib. And, if you actually intend to build a JSF 2.2 targeted web application (first doublecheck version in faces-config.xml if it matches), then keep in the javax.faces-2.2.5.jar and get rid of those jsf-api-2.1.13.jar and jsf-impl-2.1.13.jar files.

I had this same error but using WildFly. Don't know why but, I couldn't see the CDI facet option to add to my project. So in order to suppress this error message I had to create the beans.xml manually inside WEB-INF folder.

That was the content:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        bean-discovery-mode="all" version="1.1" 
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
        http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"/>

cheers

Very weird behavior on my side, I had the exact same issue with wildfly 14.

It suddenly started to work again, when i renamed one of my beans called as a validator in a httpInputText. I renamed it from "my_Bean" to "myBean" removing the underscore "_".

I do not have a beans.xml under web-inf. And i did not used maven dependency for CDI. Doing this trick worked. Hope it will fix some of the issues for other people.

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