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 the Author

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

Comments

avatar
4 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
InayathullaVersion hell with JSFUnit, Arquillian, and (embedded) Glassfish and other containers « The Holy JavaJSF 2.0 TutorialsJSF 2.0 hello world example Recent comment authors
newest oldest most voted
Inayathulla
Guest
Inayathulla

Good Job mkyong!

trackback
Version hell with JSFUnit, Arquillian, and (embedded) Glassfish and other containers « The Holy Java

[…] It seems that you can test only JSF 2.0 applications (well, you hopefully will be able to test them once Beta2 is out); if you try to test a JSF 1.2 application you will run into conflicting APIs, resulting for example in IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory. […]

trackback
JSF 2.0 Tutorials

[…] java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory […]

trackback
JSF 2.0 hello world example

[…] java.lang.IllegalArgumentException: javax.faces.context.ExceptionHandlerFactory […]