Published on Feb 26 2013 in Java Tomcat

If you build a JSF based application that works fine in your local development environment but fails to work after uploading to production server you may find thejava.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet error in your application server log.

Here is the erro message:

SEVERE: Error loading WebappClassLoader 
delegate: false 
repositories: 
/WEB-INF/classes/ 
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@16fd0b7 
javax.faces.webapp.FacesServlet 
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet

Most possible cause is that JSF libraries are missing. These could have been included in your local development environment classpath in a way but have not been bundled into the final WAR file. You should check locally why this happened and correct it for the future.

But for now, to recover from this error simply download latest JSF 2.1 or JSF 1.2 libraries (jars) from http://www.oracle.com/technetwork/java/javaee/download-139288.html or directly from https://javaserverfaces.java.net/download.html

In case of JSF 2.1 you get a single jar (for example javax.faces-2.1.17.jar) to put into Tomcat's lib or your application's WEB-INF/lib directory.

In case of JSF 1.2 you get zip archive (for example mojarra-1.2_14-binary.zip) so unpack it and get jsf-api.jar and jsf-impl.jar from lib directory inside the archive. Have the jars located in Tomcat's lib or your application's WEB-INF/lib directory or your application server's classpath whatever suits you best.

Do not forget to restart your application server and optionally check its logs to confirm the error is gone and no other error messages are present.