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:

<dependencies>
  <dependency>
    <groupid>org.apache.myfaces.core</groupid>
    <artifactid>myfaces-api</artifactid>
    <version>1.1.6</version>
    <scope>compile</scope>
  </dependency></dependencies>
 
  <dependency>
    <groupid>org.apache.myfaces.core</groupid>
    <artifactid>myfaces-impl</artifactid>
    <version>1.1.6</version>
    <scope>compile</scope>
  </dependency>
 
  ...more stuff

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

The views expressed here are the personal views of the author.

Posted on April 20, 2009 at 11:14 pm by Paul Brabban · Permalink
In: Java · Tagged with: , , , , ,

2 Responses

Subscribe to comments via RSS

  1. Written by Bima
    on June 19, 2009 at 8:13 am
    Permalink

    Thank you for your advice.. it’s work to me too

  2. Written by Paul Brabban
    on June 20, 2009 at 9:01 am
    Permalink

    @Bima: Glad it helped, took me ages to work out what was wrong!

Subscribe to comments via RSS

Leave a Reply