【问题标题】:contains invalid expression(s): javax.el.ELException:包含无效表达式:javax.el.E​​LException:
【发布时间】:2013-07-31 19:37:47
【问题描述】:

运行时出错:

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

问题:

  1. 我该如何调试这个?
  2. 找不到 ExpressionFactory 类型:org.apache.el.E​​xpressionFactoryImpl

这就是我所拥有的

  • NetBeans IDE 7.3
  • 雄猫 7.0
  • MySql 连接

这是 Murach 书中的一个简单的 sql 网关

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>

我认为 servlet 没有任何问题,但如果您需要我发布它,请告诉我。

【问题讨论】:

  • 书中引用的Tomcat版本是什么?
  • 看起来 EL 库有问题。您是使用 maven 开发此项目还是将其创建为 Web 项目?
  • Tomcat 6.x。感谢回复
  • @LuiggiMendoza 它是一个网络项目
  • @RomanC 你的意思是什么?该应用程序应该在 Tomcat 6 和 7 上都能正常运行。

标签: java jsp jstl el


【解决方案1】:

会不会是我的 el-api.jar 文件有问题

您应该在您的 web 应用程序的 /WEB-INF/lib 中包含任何特定于 servletcontainer 的 JAR 文件。 Servletcontainer 特定的 JAR 文件应该已经由 servlet-container 本身提供。

查看 Tomcat 的 /lib 文件夹,它已经提供了内部库、JSP、Servlet 和 EL 库。你不需要通过你的 webapp 提供它们中的任何一个。如果您仍然这样做,运行时类路径可能会因存在重复的不同版本库而导致灾难。在您的特定情况下,您可能通过您的 web 应用程序提供了一个随机下载的 EL API,它与在运行时类路径中找到的 EL impl 不匹配,因此无法通过抽象工厂模式找到正确的 impl。

因此,如果您在 /WEB-INF/lib 中删除特定于 servletcontainer 的 JAR,那么一切都会好起来的。 /WEB-INF/lib仅包含特定于 web 应用程序本身且 servletcontainer 尚未提供的库。

另见:

【讨论】:

  • 好的,谢谢。当我提到 el-api.jar 文件时,我正在查看 Tomcat 的 lib 文件夹。我的 /WEB-INF/Lib 中没有 el-api.jar。我怀疑罐子有问题的原因是……嗯,这只是我现在遇到的一个奇怪的问题……但是感谢您提供意见……
  • 这很奇怪。至少,事实上,你的运行时类路径是一团糟。您是否曾经摆弄过松散的特定于 servletcontainer 的 JAR 文件?例如。在 JDK/JRE 的 /lib/lib/ext 中粗心地尝试修复编译错误?
  • 我希望我做到了,那么我至少我知道我做错了什么......我要重新安装tomcat和我的IDE,看看它是否能解决问题......谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-02-16
  • 2013-11-27
  • 1970-01-01
  • 2016-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多