Monday, January 12, 2009

java.lang.NoClassDefFoundError: javax/el/ValueExpression Fix: Exclude servlet-api from Portlet Dependencies and Include as Provided

Was getting the error when running a portlet:
"java.lang.NoClassDefFoundError: javax/el/ValueExpression"
(see also: Since the project was using Maven 2, I ran the following command:
mvn dependency:tree
then I found out that one of the dependencies (cas:casclient:2.1.1) was including servlet-api (jar) which should not be included in portlets, but they should be "provided" scope since the jar should be available via Tomcat's common/lib. I added the exclusion to that dependency in pom.xml:
and because it happened to be needed for the code to compile, add it as a provided dependency:
Note: it is probably a good idea to use whatever servlet-api version works with your webapp server/platform. For example: (from
Servlet/JSP Spec   Apache Tomcat version
2.5/2.1            6.0.18
2.4/2.0            5.5.27
2.3/1.2            4.1.39
2.2/1.1            3.3.2
Note that certain versions of Maven 2 have a bug (referenced I think in (MNG-2205 and MNG-3890) related to provided scope. If this is the case for you, you could try updating Maven 2 to a newer version, and at time of writing, that means having to build a new version of Maven 2. The issue I ended up with on top of this is that I wasn't removing the webapp that I was using uPortal deployPortletApp with locally and then zipping back up for actual deployment. I fixed that script,, so if you use it, please go back and get the newer version.

No comments: