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.
我有一个web项目,其中有JSF 1.2和在tomcat 6.0.18.0中运行的Facelets。我决定升级servlet容器,因此我部署在tomcat 7中,直到我们用我的custome facelet函数访问一个视图时,一切看起来都是ok的。
javax.el.ELException: Failed to parse the expression [{pz:instanceof(object,'com.project.domain.MyClass')}]
javax.el。ELException:未能解析表达式[{pz:instanceof(对象,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.
如果我正确理解,它会抛出一个错误,因为表达式中的冒号。我已经跟踪到了在tomcat/lib目录中附带的jasper-el,如果我替换jasper。jar和jasper-el。jar与tomcat 6.0.18的所有设计都很好。
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.
在升级tomcat之前,还有其他人有这个问题吗?他们是如何解决的?我可以将这些jasper jar从tomcat 6中部署到生产tomcat 7中,或者这会导致进一步的问题。
4 个解决方案
#1
17
This is actually a misleading exception. It has a different underlying cause. The function name instanceof
is invalid.
这实际上是个误导性的例外。它有不同的根本原因。函数名instanceof是无效的。
The EL 2.2 specification says the following:
EL 2.2规范说明如下:
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 modNote 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}
.
如果Java语言标识符代表诸如instanceof、if、class、return、static、new等关键字,那么它们在EL中可能不会用作变量/函数名。如果您有这些名称的属性,请使用括号表示法来代替#{bean['class']。simpleName }而不是# { 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.
这是在Tomcat 7.0.4中被修复的,或者是在这个版本之前的某个地方,正如第50147号所指出的那样,有人指出了与您相同的问题。为了解决你的问题,你需要将你的EL函数名重命名为instanceof之类的。
#2
8
Add this line in catalina.properties ([tomcat folder]/conf), and it should fix the issue.
把这条线加到卡特琳娜。属性([tomcat文件夹]/conf),它应该解决这个问题。
org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true
However, you should not use the reserved words.
但是,您不应该使用保留字。
#3
5
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.
您还可以尝试更改语法。当我们从Tomcat 6移动到7时,我在维护代码时遇到了同样的问题。我必须更改myobject.class.name到myobject['class'].name。在我做了这个修改之后,我的代码又恢复了正常。
#4
2
Great hint, indeed! I had to change in my jspx ${instance.class.simpleName == ...} with ${instance['class'].simpleName eq ...}.
伟大的提示,的确!我必须改变我的jspx ${instance.class。simpleName = =…与$ { }实例(类的)。simpleName情商…}。
I was moving from vFabric on tomcat 6 to vFabric on tomcat 7
我从tomcat 6的vFabric到tomcat 7的vFabric。
#1
17
This is actually a misleading exception. It has a different underlying cause. The function name instanceof
is invalid.
这实际上是个误导性的例外。它有不同的根本原因。函数名instanceof是无效的。
The EL 2.2 specification says the following:
EL 2.2规范说明如下:
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 modNote 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}
.
如果Java语言标识符代表诸如instanceof、if、class、return、static、new等关键字,那么它们在EL中可能不会用作变量/函数名。如果您有这些名称的属性,请使用括号表示法来代替#{bean['class']。simpleName }而不是# { 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.
这是在Tomcat 7.0.4中被修复的,或者是在这个版本之前的某个地方,正如第50147号所指出的那样,有人指出了与您相同的问题。为了解决你的问题,你需要将你的EL函数名重命名为instanceof之类的。
#2
8
Add this line in catalina.properties ([tomcat folder]/conf), and it should fix the issue.
把这条线加到卡特琳娜。属性([tomcat文件夹]/conf),它应该解决这个问题。
org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true
However, you should not use the reserved words.
但是,您不应该使用保留字。
#3
5
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.
您还可以尝试更改语法。当我们从Tomcat 6移动到7时,我在维护代码时遇到了同样的问题。我必须更改myobject.class.name到myobject['class'].name。在我做了这个修改之后,我的代码又恢复了正常。
#4
2
Great hint, indeed! I had to change in my jspx ${instance.class.simpleName == ...} with ${instance['class'].simpleName eq ...}.
伟大的提示,的确!我必须改变我的jspx ${instance.class。simpleName = =…与$ { }实例(类的)。simpleName情商…}。
I was moving from vFabric on tomcat 6 to vFabric on tomcat 7
我从tomcat 6的vFabric到tomcat 7的vFabric。