java.lang.IllegalStateException : Could not find backup for factory javax.faces.context.FacesContextFactory

IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory

This exception is easier to understand if you replace "backup" by "implementation". It ultimately boils down to "I found the JSF API, but nowhere a JSF impl in the same classpath context as where I found the JSF API". In other words, you've a JSF API somewhere in runtime classpath which isn't accompanied with any JSF impl. E.g. having a jsf-api.jar or even javaee.jar without any jsf-impl.jar or javax.faces.jar in the same classpath context. Note that a web application can have multiple classpath contexts. The JSF impl has to be present in exactly the same location as the first encountered JSF API according to the classloading rules, and you need to make absolutely sure that there are no duplicate and/or conflicting versions.

In your specific case,

I had added this jars to my project : jstl-1.2.jar and javax.faces-api-2.2.jar

The javax.faces-api-2.2.jar alone is not right. There are 2 problems:

  • That's the "blueprint" API JAR, intented for JSF implementors such as Mojarra and MyFaces.
  • You forgot the JSF implementation JAR.

Provided that you'd like to use Mojarra, follow the installation instructions in its README. In your specific case, get rid of that javax.faces-api-2.2.jar and put the latest javax.faces-2.x.x.jar in /WEB-INF/lib or pom.xml and this exception should disappear.

See also:

  • How to properly install and configure JSF libraries via Maven?

Tags:

Tomcat

Jsf

Jsf 2