2

i was running my JSF 2 application from external tomcat 6 from eclipse and everything was working fine but when i tried to use maven tomcat plugin

mvn tomcat:run

i got the following exception on one of the pages:

java.lang.NoSuchMethodError: javax.el.ELResolver.invoke(Ljavax/el/ELContext;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;
    at com.sun.el.parser.AstValue.getValue(AstValue.java:111)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
    at javax.faces.component.UIData.getValue(UIData.java:731)
    at javax.faces.component.UIData.getDataModel(UIData.java:1798)
    at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484)
    at javax.faces.component.UIData.setRowIndex(UIData.java:473)
    at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:81)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
    at javax.faces.component.UIData.encodeBegin(UIData.java:1118)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1754)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    at com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:163)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:410)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)

any ideas why ?

Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498

2 Answers2

9

java.lang.NoSuchMethodError: javax.el.ELResolver.invoke(Ljavax/el/ELContext;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;

That method was introduced in EL 2.2. This exception suggests that your webapp's /WEB-INF/lib is polluted with libraries of an older EL version. Tomcat 7.0 itself already ships with EL 2.2, but any container-specific libraries in /WEB-INF/lib will get precedence in classloading. Perhaps you've declared a non-provided EL 2.1 dependency in pom.xml instead of a provided EL 2.2 dependency.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • the only dependency i am using is : ` org.glassfish.web el-impl 2.2 ` and the external tomcat i was using was tomcat 6 not 7 so any suggestions ? – Mahmoud Saleh Oct 17 '11 at 12:06
  • Oh, it's the other way round, you're using the old Tomcat 6. It ships with EL 2.1. You should upgrade to Tomcat 7 or to change the EL version to 2.1 (and make it `provided`). – BalusC Oct 17 '11 at 12:09
  • what will be the use of provided here ? – Mahmoud Saleh Oct 17 '11 at 12:11
  • It means that the target container already ships with it, so that you don't need to pollute webapp's `/WEB-INF/lib` with unnecessary and possibly conflicting libraries. – BalusC Oct 17 '11 at 12:12
  • all the 2.1 releases of org.glassfish.web was beta, so can you please suggest me another EL library to use with tomcat and JSF 2. – Mahmoud Saleh Oct 17 '11 at 12:19
  • As said, Tomcat 6 **already** ships with EL 2.1. Just mark it `provided` or remove the dependency altogether. I also wonder why you would ever include EL dependencies of a *different* server (Glassfish) instead of Tomcat's own from `org.apache.el` package. – BalusC Oct 17 '11 at 12:20
  • when i removed the dependency as you said, i got the following 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.E actoryImpl. If not using JSP or the EL RI, make sure the context initialization parameter, com.sun.faces.expressionFactory, is properly set`. – Mahmoud Saleh Oct 17 '11 at 12:33
  • 1
    That shouldn't happen. Tomcat 6 is by itself already a JSP 2.1 implementation. This error would mean that the webapp's `/WEB-INF/lib` is polluted with a `jsp-api.jar` or a `j2ee.jar` file which is older than JSP 2.1. Or perhaps the webapp's `web.xml` is incorrectly been declared as Servlet 2.4 or older. – BalusC Oct 17 '11 at 12:36
  • there's something which is confusing me here, is the maven tomcat pluginruns the external tomcat which is version 6 ?, or uses other embeded version than the external one ? – Mahmoud Saleh Oct 17 '11 at 12:39
  • Sorry, I don't use Maven, so I can't go in detail about that. I'm just translating the errors in layman's terms for you. – BalusC Oct 17 '11 at 12:41
  • aha, that's why there's a misunderstanding, coz if you have noticed, i told you that it everything is working fine when running tomcat from eclipse. btw, i only have in the lib folder jsp-api-2.1.jar, and i don't have any jsp-api jars or j2ee jars. – Mahmoud Saleh Oct 17 '11 at 12:54
  • You should **not** have `jsp-api.jar` in your `/WEB-INF/lib` as well. Tomcat **already** ships with it. Maven must also be told to not include that in the built WAR, you can do that by setting the dependency scope to `provided`. You should never ever have container specific libraries in `/WEB-INF/lib`. See also this related question: http://stackoverflow.com/questions/4076601/how-do-i-import-the-javax-servlet-api-in-my-eclipse-project – BalusC Oct 17 '11 at 12:54
  • it worked fine after i provided jsp-api.jar, and also removing the following lines from web.xml: ` com.sun.faces.expressionFactory com.sun.el.ExpressionFactoryImpl ` – Mahmoud Saleh Oct 17 '11 at 13:39
  • Delighted to find this question was already posted. Don't forget to check the transient dependencies of things you've got added to your classpath: Thanks to BalusC's advice I found a rogue EL2.1 transient dependency of an Oracle Weblogic dependency that I'd provided via Maven. This was the root cause of this error for me. – 8bitjunkie Jan 04 '13 at 15:06
1

If you are using Tomcat6 and Maven together, remove el-api.jar from your bin folder because maven has already added it to your project.In pom.xml , be sure to add version tag related with el-api library. I tried this solution and it's working now!

    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>el-api</artifactId>
        <version>2.2</version>
    </dependency>
dogankadriye
  • 538
  • 3
  • 13