AnsweredAssumed Answered

LinkageError / NoSuchMethodError when using with JSF2

Question asked by iravanchi on Sep 19, 2010
Latest reply on Sep 20, 2010 by jbarrez

I'm setting up my Activiti app with Tomcat, Spring, and JSF 2 (MyFaces) Frontend.
The problem is clashing EL library used by Activiti (JUEL) with the EL specification used by Tomcat and MyFaces.

By default, I get a LinkageError for ELResolver interface when starting the MyFaces listener in Tomcat.
First, I thought it is because there are two ELResolver definitions in the classpath (one in juel, and one in Tomcat's el-api.jar).
So I replaced el-api in tomcat\lib with juel. No luck!

I even searched every JAR file in the JDK, Tomcat, and my WEB-INF\lib, and the only ELResolver present was juel's. But I still get that LinkageError.

Anyway,… I thought the better way to do so is to remove the redundant EL API. So, I added an "exclusion" in the my pom.xml (maven) to omit JUEL jar file as the dependency, and added juel-impl myself (only having the EL implementation, not the API). So that I can use Tomcat without any change outside my webapp. This time, I get a NoSuchMethorError, in the constructor of ProcessEngineFactoryBean (javax.el.ExpressionFactory.newInstance()).
The method is not present in the Tomcat's included EL-API, and I guess it is a change in the JSR Spec that is included in JUEL but not in the EL-API.

So, right now I'm stuck. This was as far as I could go. The alternate option for me is to change the Activiti source code.
Any recommendations?

Here are the exception traces:

Originally, or when replacing the el-api.jar with juel.jar:
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.addELResolver(Ljavax/el/ELResolver;)V" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/apache/myfaces/webapp/Jsp21FacesInitializer, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ELResolver used in the signature
   at org.apache.myfaces.webapp.Jsp21FacesInitializer.configureResolverForJSP(
   at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(
   at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(
   at org.apache.myfaces.webapp.StartupServletContextListener.initFaces(
   at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(
   at org.apache.catalina.core.StandardContext.listenerStart(
   at org.apache.catalina.core.StandardContext.start(

When using juel-impl:
Caused by: java.lang.NoSuchMethodError: javax.el.ExpressionFactory.newInstance()Ljavax/el/ExpressionFactory;
   at org.activiti.engine.impl.el.ExpressionManager.<init>(
   at org.activiti.engine.impl.cfg.ProcessEngineConfiguration.<init>(
   at org.activiti.engine.impl.cfg.spring.ProcessEngineFactoryBean.<init>(
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
   at java.lang.reflect.Constructor.newInstance(
   at org.springframework.beans.BeanUtils.instantiateClass(
   … 52 more