How To Enable ExpressionLanguage-2.2 in Tomcat6 and Jetty6

EL-2.2 is part of JSR-245 MR2 (JSP-2.2) and therefor not included in Tomcat6 nor Jetty6. This will be part of Tomcat7 and Jetty7, but with a few manual steps, you can use EL-2.2 even in current containers.

EL-2.2 Implementation

Currently, the best Implementation we use is the one available from the glassfish project. An Apache implementation is ongoing and is currently available as a SNAPSHOT build, however we recommend to use el-api.jar and el-impl.jar from glassfish until it is final.

Maven

To make the 2 required jars available for your project, you can simply use maven:

    <!-- EL 2 -->
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>el-api</artifactId>
        <version>2.2</version>
        <scope>provided</scope>
    </dependency>
    <profiles>
        <profile>
            <id>jetty</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>maven-jetty-plugin</artifactId>
                        <version>${jetty-version}</version>
                        <configuration>
                            <scanIntervalSeconds>10</scanIntervalSeconds>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>javax.el</groupId>
                    <artifactId>el-api</artifactId>
                    <version>2.2</version>
                    <scope>compile</scope>
                </dependency>
                <dependency>
                    <groupId>org.glassfish.web</groupId>
                    <artifactId>el-impl</artifactId>
                    <scope>runtime</scope>
                    <version>2.2</version>
                </dependency>
            </dependencies>
        </profile>
    </profiles

Apache's EL 2.2 implementation

The above code uses Sun's EL 2.2 implementation from Glassfish. If you want to use Apache's implementation, you have to use the following dependencies from the Apache SNAPSHOT repository:

<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-el-api</artifactId>
    <version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-jasper-el</artifactId>
    <version>7.0.0-SNAPSHOT</version>
</dependency>

However keep in mind that this implementation is only a SNAPSHOT build and thus you might run into some problems with it.

web.xml settings

In addition you have to configure the right expression factory implementation in the web.xml. For Sun's EL 2.2 implementation this is com.sun.el.ExpressionFactoryImpl and for Apache's implementation this is org.apache.el.ExpressionFactoryImpl. The following snippet shows the web.xml configuration for Sun's impl.

<context-param>
    <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>

Tomcat preparation

Tomcat6 has to be prepared, otherwise it will crash with a Exception on container startup:

* 1. go to the tomcat home directory

* 2. remove tomcats el-api.jar from the classpath:

* 3. copy the EL-2.2 jars into ./lib (el-api-2.2.jar, el-impl-2.2.jar)

* 4. make sure that your WARs don't contain those 2 el jars!

HowToEnableEl22 (last edited 2010-05-25 18:52:18 by JakobKorherr)