Main Tutorials

java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory

Problem

In Eclipse IDE, while deploying a JSF 2.0 web application to Tomcat 6.0.26, hits the following exception and failed to start the Tomcat server.

P.S Both jsf-api-2.1.0-b03.jar and jsf-impl-2.1.0-b03.jar libraries are included in the project classpath.


INFO: Unsanitized stacktrace from failed start...
java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory
	at javax.faces.FactoryFinder.validateFactoryName(FactoryFinder.java:630)
	at javax.faces.FactoryFinder.setFactory(FactoryFinder.java:287)
	...
SEVERE: Critical error during deployment: 
com.sun.faces.config.ConfigurationException: 
CONFIGURATION FAILED! javax.faces.context.ExceptionHandlerFactory
	...
Caused by: java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory
	at javax.faces.FactoryFinder.validateFactoryName(FactoryFinder.java:630)
	...

Solution

In Eclipse debugging mode, dig inside the source code, find out the IllegalArgumentException is thrown by the FactoryFinder’s getFactory() method.

FactoryFinder.java


 /*
 * @throws IllegalArgumentException if <code>factoryName</code> does not
 *                                  identify a standard JavaServer Faces factory name
 * @throws IllegalStateException    if there is no configured factory
 *                                  implementation class for the specified factory name
 * @throws NullPointerException     if <code>factoryname</code>
 *                                  is null
 */
	 
 public static Object getFactory(String factoryName)
         throws FacesException {

        validateFactoryName(factoryName);
        //...
 }

The IllegalArgumentException documented that the factor finder does not recognize the new JSF2.0 ExceptionHandlerFactory factory name.

After thousand times of testing and trying, finally, i find out the root cause is from the javaee.jar, which included in my project class path. Look inside the javaee.jar, it contains a set of JSF 1.2 api as well, look like the Tomcat is picking this JSF 1.2 api instead of my new JSF 2.0 api.

After remove the javaee.jar from the project classpath, the JSF 2.0 web application is able to start and running well on Tomcat.

Reference

  1. FactoryFinder.html#getFactory Javadoc
  2. JSF 2.0.3 release notes

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Inayathulla
10 years ago

Good Job mkyong!