Search code examples
jsfweblogicel

weblogic 10.3.4 java.lang.ClassNotFoundException: javax.el.ELContextListener


I have a JSF 1.2 application which I intend to deploy to Weblogic 10.3.4. At local Tomcat environment it works fine. But when I try to deploy it to weblogic I am getting a ClassNotFoundException on javax.el.ELContextListener. When I add el-api.jar file, then I get a LinkageError: loader constraint violation on javax.EL.ELResolver. It is a deadly vicious circle.

At first I tried to deploy it as WAR. Then I created an enterprise project so that I can deploy as EAR, but it did not solve the problem. My EAR file structure is fine.

Firstly I got error below,

Caused By: java.lang.ClassNotFoundException: javax.el.ELContextListener
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)

When I add el-api-2.2.jar to /WEB-INF/lib of WAR or /APP-INF/lib of EAR, then I get loader constarint error;

com.sun.faces.config.ConfigureListener failed: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.addELResolver(Ljavax/el/ELResolver;)V" the class loader (instance of weblogic/utils/classloaders/GenericClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ELResolver used in the signature.
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.addELResolver(Ljavax/el/ELResolver;)V" the class loader (instance of weblogic/utils/classloaders/GenericClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ELResolver used in the signature
    at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:582)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:212)

What is the problem with it? I changed my classpath order but result was the same. My web.xml is declared as Servlet 2.5 and I have the following JARs in /WEB-INF/lib:

  • commons-beanutils-1.7.0.jar
  • commons-collections-3.2.jar
  • commons-digester-1.8.jar
  • commons-logging-1.0.4.jar
  • darkX-3.3.3.Final.jar
  • glassX-3.3.3.Final.jar
  • jsf-api.jar
  • jsf-impl.jar
  • jstl-1.2.jar
  • laguna-3.3.3.Final.jar
  • log4j-1.2.14.jar
  • poi-3.7-20101029.jar
  • quartz-all-1.8.4.jar
  • richfaces-api-3.3.3.Final.jar
  • richfaces-impl-3.3.3.Final.jar
  • richfaces-ui-3.3.3.Final.jar
  • scjd12.jar
  • slf4j-api-1.6.0.jar
  • slf4j-log4j12-1.6.0.jar
  • themes-3.3.3.Final.jar

Solution

  • Finally I manage to find the solution.

    jsf-impl jar includes "ELContextListenerImpl" class which implements "ELContextListener" interface. And ELContextListener interface is included in the wlfullclient-10.3.X.jar in the server path.

    If you dont have wlfullclient jar in the server path you will have "ClassNotFoundException: javax.el.ELContextListener" error. Getting this error if you add el-api jar this time you will get "LinkageError: loader constraint violation" because versions of jars you used and the server has are different. Anyway the problem will be resolved after creating wlfullclient-10.3.X.jar in the weblogic server.

    In order to create that jar you can read this post: http://wls4mscratch.wordpress.com/2010/06/19/steps-to-build-a-wlfullclient-jar-in-wls-10-0-x-and-wls-10-3-x/