«

»

Nov
25

For JSF 2.0, How to Enable EL 2.2 on Tomcat 6

How to Enable EL 2 for Java Server Faces 2.x on server running older EL version

EXCEPTION: com.sun.faces.config.ConfigurationException: It appears the JSP version of the container is older than 2.1 and unable to locate the EL RI expression factory, com.sun.el.ExpressionFactoryImpl.  If not using JSP or the EL RI, make sure the context initialization parameter, com.sun.faces.expressionFactory, is properly set.

If you are developing with JSF 2 then your biggest wishes come true, like parameter passing in method via EL and many more JSF 2 powerful features you can enjoy.

Many things are now enabled but with have to activate EL 2.2 on your web container specially if you are working with tomcat 6 or below versions.

EL 2x allows you to pass in parameters in your method expression (i.e. actions and action listeners). See example below:


<h:commandButton id="btnSave" value="Save" action="#{CustomerRegistration.saveCustomer(customer)}" />

Tomcat 6 is using older EL (Expression Language and does not ship with 2.2, you have to manually upgrade EL on your tomcat by following steps.

  • Delete el-api.jar in tomcat’s lib direcotry
  • Put el-api-2.2.jar and el-impl-2.2.jar) in the Tomcat “lib” folder

You can download EL 2.2 from Glassfish project

http://download.java.net/maven/glassfish/javax/el/el-api/2.2.0-SNAPSHOT/el-api-2.2.0-SNAPSHOT.jar

http://download.java.net/maven/glassfish/org/glassfish/web/el-impl/2.2.0-SNAPSHOT/el-impl-2.2.0-SNAPSHOT.jar

In the web.xml, add the following if you are using Sun’s Mojarra implementation of JSF


<context-param>
 <param-name>com.sun.faces.expressionFactory</param-name>
 <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>

For Apache MyFaces’s implementation of JSF


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

Alternatively, you can also use Apache’s EL 2.2 implementation instead of Glasssfish, See the following guidelines

http://wiki.apache.org/myfaces/HowToEnableEl22″ target=”_blank”>http://wiki.apache.org/myfaces/HowToEnableEl22

References:

You will be getting following exception, probably if EL problem is there on your server.


SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
com.sun.faces.config.ConfigurationException: It appears the JSP version of the container is older than 2.1 and unable to locate the EL RI expression factory, com.sun.el.ExpressionFactoryImpl.  If not using JSP or the EL RI, make sure the context initialization parameter, com.sun.faces.expressionFactory, is properly set.
 at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:639)
 at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:238)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
 at org.apache.catalina.core.StandardService.start(StandardService.java:525)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Dec 1, 2011 4:28:34 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
VN:F [1.9.14_1148]
Rating: 9.5/10 (2 votes cast)
VN:F [1.9.14_1148]
Rating: +1 (from 1 vote)
For JSF 2.0, How to Enable EL 2.2 on Tomcat 6, 9.5 out of 10 based on 2 ratings

About the author

Faisal Basra

Faisal Basra is an independent consultant, software developer, writer, blogger, speaker, architect and technology leader in Lahore, Pakistan. He has been a professional software developer since 2008, has been writing code since 2006.Having hands on experience of popular Java EE frameworks & technologies like JSF, Spring, Hibernate, Enverse, JPA, Richfaces, Primefaces, JSP/Servlet.Tools & Servers: jUnit, Log4j, Maven, Eclipse, MyEclipse, NetBeans, Tomcat, Jboss, WebLogicMobile Development: Google Android

Permanent link to this article: http://www.javaplex.com/blog/for-jsf-2-how-to-enable-el-2-2-on-tomcat-6/

Leave a Reply

Your email address will not be published.

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=""> <strike> <strong>