Spring 3 - Petclinic - $ {owner.new} invalid expression in Tomcat 7

I deployed the lapel code from the SPring 3 svn sample repository in Tomcat7, and I got the following exception:

Internal error

Root reason: /WEB-INF/jsp/owners/form.jsp (4,1) "$ {owner.new}" contains invalid expressions: javax.el.ELException: [new] is not a valid Java identifier org.apache. jasper.JasperException: /WEB-INF/jsp/owners/form.jsp (4,1) "$ {owner.new}" contains invalid expressions: javax.el.ELException: [new] is not a valid Java identifier

This expression does a great job with SpringSurce tc Server Developer Edition 2.0.

Any ideas why Tomcat 7.0.2 has problems with this?

+4
source share
4 answers

Bozho has ever reported this error: 50147 - static is not a valid identifier .

It comes down to:

An important part of this discussion is given on page 21 (EL specifications).

  Identifier :: = Java language identifier 

The Java language identifier is determined by the Java Language Specification (JLS).

Identifiers are listed in JLS chapter 3.8 , which really confirms that identifiers may not be a keyword. According to the bug report, you need to access it as follows:

${owner['new']} 

or

 ${owner.isNew()} 
+4
source

The EL specification does not allow the use of Java keywords as identifiers. "new" is a Java keyword, and therefore $ {owner.new} is not a legal EL. Tomcat 7 applies this rule by default (Tomcat 6 does not support backward compatibility). The error is in the sample Spring application.

+2
source

I assume that the EL parser in Tomcat 7 is slightly more strict than in tcServer (which is based on Tomcat 6).

I suggest writing down the http://jira.springsource.org error, which is almost certainly what they want to fix.

+1
source

It will work with ${owner.isNew()} instead of ${owner.new} .

0
source

All Articles