Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: Release 1.5.7
-
Fix Version/s: None
-
Component/s: Validation
-
Labels:None
-
Environment:Stripes 1.5.7 running under Tomcat 7.0.29, Java 1.6.0_33-b03-424-11M3720 on Mac OS X (10.8).
Description
I am testing the upgrade to 1.5.7 on an existing (working) project. Everywhere I use @Validate(expression) I am now getting errors/stacktraces. For example, I have an ActionBean with this:
@ValidateNestedPropertes({
@Validate(field = "password", required = true, minlength = 8)
})
MDUser user;
@Validate(required = true, expression = "this == user.password")
String passwordConfirm;
And when I submit the form I get this error in Tomcat:
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalArgumentException: can't parse argument number this == user.password
at java.text.MessageFormat.makeFormat(MessageFormat.java:1339)
at java.text.MessageFormat.applyPattern(MessageFormat.java:458)
at java.text.MessageFormat.<init>(MessageFormat.java:368)
at net.sourceforge.stripes.action.SimpleMessage.getMessage(SimpleMessage.java:95)
at net.sourceforge.stripes.validation.SimpleError.getMessage(SimpleError.java:102)
at net.sourceforge.stripes.tag.ErrorsTag.doEndTag(ErrorsTag.java:349)
at org.apache.jsp.WEB_002dINF.layout.admin.default_002dadmin_jsp._jspService(default_002dadmin_jsp.java:293)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
Ok I may have jumped the gun here.
The ultimate problem was the Java EL spec doesn't like it when you use Java identifiers in an expression. So the use of "this" is the problem. I had actually run into this problem earlier in development and worked around it by adding the flag -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true to the Tomcat startup script. Somehow this got turned off in my IDE coinciding with the upgrade to Stripes 1.5.7 which is why I thought that was the problem.
But I am puzzled as to why the exception I'm getting isn't the usual one. I'd expect to see something like:
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /WEB-INF/jsp/xxx.jsp(100,0) “${this == user.password}”
contains invalid expression(s): javax.el.ELException: [this] is not a valid Java identifier
But instead I'm seeing:
java.lang.IllegalArgumentException: can't parse argument number this == user.password
Any ideas?