Saturday Dec 10

Links

Books

User Menu

AddThis

AddThis Social Bookmark Button

Unified Expression Language and JSF 2

PDF Print E-mail
Wednesday, 11 May 2011 06:48
AddThis Social Bookmark Button

Unified Expression Language 2.2

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

Add Unified expression language in your Java server faces project using Maven

Include the following snippet in the dependencies section of your project's pom.xml-file to get EL2 :

javax.el dependencies maven

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>el-api</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>el-impl</artifactId>
    <version>2.2</version>
</dependency>

Include the java.net repository project's pom.xml-file or in your settings.xml :

Unified expression language repository download location

<repository>
   <id>java-net</id>
   <url>http://download.java.net/maven/2/ </url>
</repository>  

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.

Include the following snippet in the <dependencies> section of your project's pom.xml-file:

Apache EL 2.2 Maven configuration

<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>

web.xml settings

Include the following snippet in the <build><plugins> section of your project's pom.xml-file:

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

Tomcat 6 Configuration for EL 2.2

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:

Tomcat6 el-api el-impl Expression Language

> mv ./lib/el-api.jar ./lib/el-api.jar.bak

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!

Tags: groupid , artifactid , dependency , /artifactid , version , /dependency , /version , project's , include , pom.xml-file , el-2.2

Add comment


Security code
Refresh