Announcement Announcement Module
Collapse
No announcement yet.
Getting Linkage error while trying to show the error set in controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Linkage error while trying to show the error set in controller

    Hi,

    I am getting this wierd exception:
    javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/jasper/servlet/JasperLoader) previously initiated loading for a different type with name "javax/el/ExpressionFactory

    I am trying to develop a simple login page which has username in first page and on the second page we have to show user's security image and ask for password. Here is what I did:

    1. Implemented a LoginController class which shows the login.jsp form in first request.
    2. If user submits a blank username then LoginValidator handles that and show the login form again with the error.
    3. If user enters a username, which passes the validator and the request reaches the onSubmit() in LoginController. In the LoginController, security image is retrieved based on the username and then redirected to success view.
    4. Till here everything is working fine. Now the problem starts when there is no security image for a user and we have to show the loginform again with an error message. This is what I did:
    Code:
     if (securityImagePath == null)
     {
         errors.reject("no.security.image", "Security Image not found");
         return showForm(request, response, errors);
     }
    5. Below is my JSP implementation to show this error message:
    Code:
    <spring:hasBindErrors name="loginBean">
        <b>Please fix all errors!</b> 
    	<p>There were ${errors.errorCount} errors</p> 
    	<c:forEach var="errMsgObj" items="${errors.allErrors}">
    	   <li>
    		  <spring:message code="${errMsgObj.code}" text="${errMsgObj.defaultMessage}"/>
    	   </li>
    	</c:forEach>
    </spring:hasBindErrors>
    So, when the login form is shown again to show this error, it gives the below error:
    Code:
    javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/jasper/servlet/JasperLoader) previously initiated loading for a different type with name "javax/el/ExpressionFactory"
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)
    org.apache.jsp.com_satmetrix_core_webui_app_WebUI.login.login_jsp._jspService(login_jsp.java:782)
    I figured out that it is below piece of code which is causing this issue. If i remove this code from my JSP page then no exception occurs but also "Security Image not found" error message is also not shown.
    Code:
    <c:forEach var="errMsgObj" items="${errors.allErrors}">
    	   <li>
    		  <spring:message code="${errMsgObj.code}" text="${errMsgObj.defaultMessage}"/>
    	   </li>
    	</c:forEach>
    We are using JBoss 4.2 as server. I have checked and I don't have el-api.jar in my WEB-INF/lib folder. Only jar which contains this "javax/el/ExpressionFactory" class is jsp-api-2.1.jar.

    Any help is much appreciated !!! This issue is killing me.

  • #2
    On further investigation, i found that there is el-api.jar in jboss lib which was conflicting with jsp-api-2.1.jar. So, i removed el-api.jar from jboss and moved jsp-api-2.1.jar from my project's web-inf/lib to jboss lib and it resolved this issue. There should be only one instance of jsp-api-2.1.jar in entire classpath. If you have multiple jars then also you will get this error.

    Comment

    Working...
    X