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/ELResolverV" 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(Jsp21FacesInitializer.java:123) at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:77) at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:113) at org.apache.myfaces.webapp.StartupServletContextListener.initFaces(StartupServletContextListener.java:186) at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:159) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
When using juel-impl: Caused by: java.lang.NoSuchMethodError: javax.el.ExpressionFactory.newInstance()Ljavax/el/ExpressionFactory; at org.activiti.engine.impl.el.ExpressionManager.<init>(ExpressionManager.java:55) at org.activiti.engine.impl.cfg.ProcessEngineConfiguration.<init>(ProcessEngineConfiguration.java:164) at org.activiti.engine.impl.cfg.spring.ProcessEngineFactoryBean.<init>(ProcessEngineFactoryBean.java:51) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100) … 52 more
Well, I found a way: I needed to remove JUEL from my WEB-INF\lib when I added it to tomcat's lib folder. It works now. But a solution for this issue that doesn't involve changing the Tomcat's lib folder (anything outside the context root) would be nice. I believe there's an issue registered for it in Activiti's JIRA.
It's a known issue at the moment, and we are working on it to resolve it.
The workaround is indeed as you describe: remove the juel libs from the Tomcat lib, which removes the clashes with the EL resolver of Tomcat (which is a different version of EL)