Installing and running Apache MyFaces 1.2 with RichFaces 3.3

In an attemt at learning Java Server Faces, I thought that testing out an example application would be a good starting point. After reading about pros and cons related to the many different implementations of JSF, I ended up with the following ingredients:

– Apache MyFaces Core 1.2
– JBoss RichFaces 3.3.3
– JBoss Web Tools Eclipse Plug-in
– Apache Tomcat 6.0.26
– Eclipse 3.5.2

After downloading & installing the above software, I restarted my Eclipse installation and then added a new “JSF Project” with the “JSFKickStartWithoutLibs” template (which is added when installing JBoss Web Tools). The wizard then creates a fully functional demo application without additional libraries, so the first thing I did was to add the MyFaces library to the WEB-INF/lib folder. Then trying to start the demo, however, results in this error message:

SEVERE: Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
SEVERE: Skipped installing application listeners due to previous error(s)

The above error is thrown when your project is missing the “jsf-impl.jar” which ships with the Sun RI API. The standard installation of the JBoss Web Tools does actually not include this file when creating a JSF project template, This is a very strange behaviour considiring that I installed JBoss Web Tools through the Eclipse update site.

After a few hours of trial, I finally found the solution: Simply remove all files belonging to the Sun RI API, only keeping the MyFaces library files. Remove the following: jsf-tlds.jar, jsf-api.jar, jsf-impl.jar (including other dublicate files, such as the Apache commons libs). As a last step, I also deleted standard.jar and jstl.jar, replacing these with the jstl-1.2.jar. You such also replace the following listener definition in your web.xml file:

<listener-class>com.sun.faces.config.ConfigureListener</listener-class>

with the following:

<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> 

Update your workspace, restart Tomcat and it should be working.

And heres a working copy of my demo project: JSFDemo (includes Apache MyFaces & JBoss RichFaces). Running the demo should give you something like this:

This entry was posted in Java, Web and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>