javax.el.E​​LException:无法解析表达式 [{pz:instanceof(object,'com.project.domain.MyClass')}]

发布于 2024-12-11 05:27:46 字数 840 浏览 0 评论 0原文

目前我有一个在 tomcat 6.0.18.0 中运行的带有 JSF 1.2 和 Facelets 的 Web 项目。我决定升级 servlet 容器,因此我部署在 tomcat 7 中,一切看起来都很好,直到我们使用我的自定义 Facelet 函数点击一个视图。

javax.el.E​​LException: 无法解析表达式 [{pz:instanceof(object,'com.project.domain.MyClass')}]

Caused by: org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 5. Was expecting one of:
"}" ...
"." ...
"[" ...

解析以下代码时会发生此错误:

<ui:repeat var="object" value="#{objects}">
<ui:fragment rendered="#{pz:instanceof(object,'com.project.domain.MyClass')}">
...

如果我理解正确地,它会因为表达式中的冒号而引发错误。我已经追踪到 tomcat/lib 目录中附带的 jasper-el,如果我将 jasper.jar 和 jasper-el.jar 替换为 tomcat 6.0.18 中的,则一切正常。

有没有其他人在升级 tomcat 之前遇到过这个问题?他们是如何解决的? 我可以使用 tomcat 6 中的这些 jasper jar 在生产 tomcat 7 中部署吗,或者这可能会导致进一步的问题。

Currenty I have a web project with JSF 1.2 and Facelets running in tomcat 6.0.18.0. I decided to upgrade the servlet container, thus i deployed in tomcat 7 and all seemed ok until we hit one view using my custome facelet functions.

javax.el.ELException: Failed to parse the expression [{pz:instanceof(object,'com.project.domain.MyClass')}]

Caused by: org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 5. Was expecting one of:
"}" ...
"." ...
"[" ...

This error occurs when parsing the following code:

<ui:repeat var="object" value="#{objects}">
<ui:fragment rendered="#{pz:instanceof(object,'com.project.domain.MyClass')}">
...

If i understand correctly it throws an error because of the colon in the expression . I have tracked it down to the jasper-el that come with in the tomcat/lib directory, and if I replace jasper.jar and jasper-el.jar with the ones from tomcat 6.0.18 everythign works well.

Has anyone else had this problem before upgrading their tomcat? And How did they resolve it?
Could I deploy in production tomcat 7 with these jasper jar from tomcat 6, or could this cause further problems.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

习ぎ惯性依靠 2024-12-18 05:27:46

这实际上是一个误导性的例外。它有不同的根本原因。函数名称 instanceof 无效。

EL 2.2 规范规定如下:

1.14 保留字

以下单词是为该语言保留的,不得用作
标识符。

 和 eq gt true instanceof
    或者没有假空
    不是 lt ge null div mod

  
  

请注意,其中许多单词现在不在该语言中,但它们可能在 未来,所以开发者必须避免使用这些词。

1.19 收集的语法

...

标识符 ::= Java 语言标识符

...

其中 Java 语言标识符代表关键字,例如 instanceofifwhileclass< /code>、returnstaticnew 等。它们不能在 EL 中用作变量/函数名称。如果您有具有这些名称的属性,请使用大括号表示法,例如 #{bean['class'].simpleName} 而不是 #{bean.class.simpleName}

此问题已在 Tomcat 7.0.4 或此版本之前的某个版本中修复,如 问题所示50147 其中其他人指出了与您相同的问题。因此,要解决您的问题,您必须将 EL 函数名称重命名为例如 isInstanceOf 或其他名称。

This is actually a misleading exception. It has a different underlying cause. The function name instanceof is invalid.

The EL 2.2 specification says the following:

1.14 Reserved Words

The following words are reserved for the language and must not be used as
identifiers.

    and   eq     gt     true   instanceof
    or    ne     le     false  empty
    not   lt     ge     null   div        mod

Note that many of these words are not in the language now, but they may be in the
future, so developers must avoid using these words.

and

1.19 Collected Syntax

...

Identifier ::= Java language identifier

...

Where the Java language identifier stands for keywords like instanceof, if, while, class, return, static, new, etc. They may not be used as variable/function names in EL. In case you have properties with those names, use the brace notation instead like so #{bean['class'].simpleName} instead of #{bean.class.simpleName}.

This was been fixed in Tomcat 7.0.4 or somewhere near before this version as indicated by issue 50147 wherein someone else pointed out the same problem as you have. So, to solve your problem, you have to rename your EL function name to for example isInstanceOf or something.

仄言 2024-12-18 05:27:46

在 catalina.properties([tomcat 文件夹]/conf)中添加此行,它应该可以解决问题。

org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true

但是,不应使用保留字。

Add this line in catalina.properties ([tomcat folder]/conf), and it should fix the issue.

org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true

However, you should not use the reserved words.

自演自醉 2024-12-18 05:27:46

您还可以尝试更改语法。当我们从 Tomcat 6 迁移到 7 时,我所维护的代码也遇到了同样的问题。我必须将 myobject.class.name 更改为 myobject['class'].name。进行此更改后,我的代码再次完美运行。

You can also try changing the syntax. I had the same exact problem with code that I was maintaining when we were moving from Tomcat 6 to 7. I had to change myobject.class.name to myobject['class'].name. After I made this change my code worked perfectly again.

拒绝两难 2024-12-18 05:27:46

确实是很好的提示!我必须将 jspx ${instance.class.simpleName == ...} 更改为 ${instance['class'].simpleName eq ...}。

我从 tomcat 6 上的 vFabric 迁移到 tomcat 7 上的 vFabric

Great hint, indeed! I had to change in my jspx ${instance.class.simpleName == ...} with ${instance['class'].simpleName eq ...}.

I was moving from vFabric on tomcat 6 to vFabric on tomcat 7

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文