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

I currently have a web project with JSF 1.2 and Facelets running in tomcat 6.0.18.0. I decided to update the servlet container, so I deployed to tomcat 7, and everything seemed fine until we hit one by one 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 code:

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

If I understand correctly, this causes an error due to the colon in the expression. I tracked it down to jasper-el, which is in the tomcat / lib directory, and if I replaced jasper.jar and jasper-el.jar with the ones from tomcat 6.0.18, everything works fine.

Has anyone else had this problem before updating their tomcat? And how did they resolve this? Can I deploy tomcat 7 in production using jomper jar from tomcat 6, or can this cause additional problems.

+7
source share
4 answers

This is truly a misleading exception. This has another main reason. The function name instanceof not valid.

The EL 2.2 specification says the following:

1.14 Reserved Words

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

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

Please note that many of these words are not in the language right now, but they may be in the future, so developers should avoid using these words.

and

1.19 Retired syntax

...

 Identifier ::= Java language identifier 

...

If the Java language identifier denotes keywords such as instanceof , if , while , class , return , static , new , etc. They cannot be used as variables / function names in EL. In case you have properties with these names, use the legend #{bean['class'].simpleName} instead of #{bean.class.simpleName} instead.

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

+16
source

Add this line to catalina.properties ([tomcat folder] / conf) and it should fix this problem.

 org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true 

However, you should not use reserved words.

+7
source

You can also try changing the syntax. I had the same problem with the code that I supported when we moved from Tomcat 6 to 7. I had to change myobject.class.name to myobject['class'].name . After I made this change, my code worked fine.

+5
source

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

I moved from vFabric on tomcat 6 to vFabric on tomcat 7

+2
source

All Articles