Running Apache MyFaces on Tomcat 5.5.x and below

I’ve recently been looking at JavaServer Faces (specifically Apache’s MyFaces), playing about on my home Tomcat 5.5.27 installation, using Maven2 to do my dependency management, builds etc…

…largely unsuccessfully. I just could not get the darned example app to start, with exceptions along the lines of:

20-Apr-2009 22:27:04 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.NoClassDefFoundError: javax/el/ExpressionFactory
at org.apache.myfaces.webapp.StartupServletContextListener.getFacesInitializer…

appearing in the tomcat localhost log files.

Solving the problem is easy when you know how, but it still took me a while to figure it out. There’s two versions of JSF and MyFaces, and by default when you set up your Maven project, you get the latest, greatest version, 1.2.x – which is incompatible with Tomcat versions below version 6.0. That’s what causes the exceptions above.

If you want to use Tomcat 5.5x or below, you’ll need MyFaces 1.1.x to get things working. If you’re using Maven, update the versions of myfaces-api and myfaces-impl in your pom.xml to refer to the 1.1.6 versions as follows:


  
    org.apache.myfaces.core
    myfaces-api
    1.1.6
    compile
  

  
    org.apache.myfaces.core
    myfaces-impl
    1.1.6
    compile
  

  ...more stuff

When I made these updates, the older versions were downloaded, and everything started working just fine.

About these ads

2 thoughts on “Running Apache MyFaces on Tomcat 5.5.x and below

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s