contains invalid expression(s): javax.el.ELException:

瘦欲@ 提交于 2019-12-10 21:49:50

问题


Error on run time:

index.jsp(12,8) PWC6038: "${sqlStatement == null}" contains invalid expression(s):
javax.el.ELException: Unable to find ExpressionFactory of type:
    org.apache.el.ExpressionFactoryImpl
    org.apache.jasper.JasperException: : javax.el.ELException: Unable to find ExpressionFactory of type: org.apache.el.ExpressionFactoryImpl

Questions:

  1. How would I go about debugging this?
  2. Unable to find ExpressionFactory of type: org.apache.el.ExpressionFactoryImpl <-- what does this mean?

This is what I have

  • NetBeans IDE 7.3
  • Tomcat 7.0
  • MySql connection

This is a simple sql gateway from Murach's book

index.jsp

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

    <c:if test="${sqlStatement == null}">
        <c:set var="sqlStatment" value="select * from User" />
    </c:if>

    <h1>The SQL Gateway</h1>
    <p>Enter an SQL statement and click the execute button. Then, information about the<br/>
    statement will appear at the bottom of this page.
    </p>

    <p><b>SQL Statement:</b></p>

    <form action="SqlGateway" method="POST">

        <textarea name="sqlStatement" cols="60" rows="8">${sqlStatement}</textarea>
        <br/><br/>
        <input type="submit" value="Execute">

    </form>

    <p><b>SQL result:</b></p>
    <p>${sqlResult}</p>

web.xml

    <servlet>
    <servlet-name>SqlGatewayServlet</servlet-name>
    <servlet-class>sql.SqlGatewayServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>SqlGatewayServlet</servlet-name>
    <url-pattern>/SqlGateway</url-pattern>
</servlet-mapping>

I don't think there is anything wrong with the servlet, but if you need me to post it please let me know.


回答1:


Could it be something wrong with my el-api.jar file

You should not have any servletcontainer-specific JAR file in your webapp's /WEB-INF/lib. Servletcontainer-specific JAR files are supposed to be already provided by the servlet-container itself.

Look in Tomcat's /lib folder, it already ships internal libraries, JSP, Servlet and EL libraries. You do not need to supply any of them via your webapp. If you still do it, the runtime classpath may end up in a disaster because there are duplicate different versioned libraries. In your specific case, you likely supplied a randomly downloaded EL API via your webapp which didn't match the EL impl found in the runtime classpath and thus the right impl can't be found via the abstract factory pattern.

So, if you get rid of servletcontainer-specific JARs in /WEB-INF/lib, then all should be well. The /WEB-INF/lib should contain only libraries which are specific to the webapp itself and are not already provided by the servletcontainer.

See also:

  • How do I import the javax.servlet API in my Eclipse project?


来源:https://stackoverflow.com/questions/17979369/contains-invalid-expressions-javax-el-elexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!