0

I am generating dynamic component in JSF, this is my faces-config.xml file:

<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0" >
<application>
    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    <resource-bundle>
        <base-name>build</base-name>
        <var>build</var>
    </resource-bundle>
    <resource-bundle>
        <base-name>message</base-name>
        <var>message</var>
    </resource-bundle>
    <locale-config>
     <default-locale>en</default-locale>
     <supported-locale>fr</supported-locale>
     <supported-locale>es</supported-locale>
    </locale-config>
</application>  

I got a linkage error like below

    SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.RuntimeException: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, 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/ExpressionFactory used in the signature
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:294)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

I have added the el-api jar file in my /WEB-INF/lib folder. I found one solution, the exclusion of Spring EL due to conflict. Solution is to add below code in pom.xml, but I don't have that file in my application.

 <dependencies>
    <dependency org="org.springframework" name="org.springframework.web.servlet" rev="3.0.5.RELEASE">
        <!-- Fix for java.lang.LinkageError: loader constraint violation -->
        <exclude name="com.springsource.javax.el" />
    </dependency>
</dependencies>

Where do I need to put this <dependency> tag? I don't know. In my application I've only faces-config.xml, application-context.xml and web.xml files. My application is on Spring and JSF integration. I'm using Tomcat server. It contains the files context.xml, web.xml, server.xml and tomcat-users.xml. Where do I need to put that <dependency> tag? Or is there an alternative solution? I don't want to remove el-api.jar file.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
jabiaxn
  • 1
  • 4
  • What container are you running and why are you manually including el-api.jar? This will result in a duplication and Tomcat 6+ (if your containter is based on that) has special class loading mechanisms. Generally, containers frown at multiple distributions of foundation jars being present on the classpath. Get rid of dupes – kolossus Jan 16 '13 at 06:29

1 Answers1

1

The <dependency> tag is part of Maven. Maven is a dependency management tool which enables you to manage dependencies without the need to manually carry loose JAR files around. In essence, Maven will automatically download the right compiletime dependencies and Maven will automatically fill the /WEB-INF/lib with the right runtime dependencies, all based on configuration in pom.xml. The entry which you've there basically tells Maven to exclude the Spring EL dependency from inclusion in /WEB-INF/lib.

As you're not using Maven, you have in essense just to do exactly the same as what Maven would be doing under the covers: not placing the Spring EL JAR file in /WEB-INF/lib.

However, I wonder if that's the right solution. I don't think so.

The EL API is by default already provided by Tomcat itself. So placing your own in /WEB-INF/lib would only cause problems if it's not of the same version. You're not clear on why you don't want to remove it, perhaps you incorrectly thought that the particular JAR file would solve a particular problem which you didn't tell anything about, but after all it's actually the wrong solution.

Keep the /WEB-INF/lib free of libraries which are already offered by the servletcontainer itself. Whatever problem you thought to solve with placing EL API JAR in /WEB-INF/lib has to be solved differently. Perhaps you were using Eclipse and are trying to fix javax.el compilation errors the wrong way. See then the 2nd link below for the right solution.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555