EL 2.2 in Tomcat 7 throws
javax.el.PropertyNotFoundException: Property 'xAxis' not found on type ...
when I try to access the following propery
private XAxis xAxis;
public XAxis getXAxis() {
return xAxis;
}
like so
${bean.xAxis}
in a JSP.
In my understanding of both the JavaBeans and the EL spec getXAxis
is the proper accessor for the xAxis
property. Lombok agrees with me, it also generates a getXAxis
method. The "Getter and Setter" generator in Eclipse, however, disagrees as it generates getxAxis
.
Update
I meanwhile found out a few things:
- there's a 'won't fix' issue for Lombok for this case
- all 3 major IDEs seem to generate
getxAxis
- there's a nice blog post dedicated to this corner case, it's referenced in https://stackoverflow.com/a/16146215/131929 and quotes chapter 8.8 of the Java Beans spec
Still, I fail to understand how chapter 8.8 of the Java Beans spec is applicable here as it describes different cases. To me this looks much more of an implementation detail of java.beans.Introspector#decapitalize
than a clearly defined behavior.
public static String decapitalize(String name) {
if (name == null || name.length() == 0) {
return name;
}
if (name.length() > 1 && Character.isUpperCase(name.charAt(1)) &&
Character.isUpperCase(name.charAt(0))){
return name;
}
char chars[] = name.toCharArray();
chars[0] = Character.toLowerCase(chars[0]);
return new String(chars);
}
The spec says
Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to lower case. However to support the occasional use of all upper-case names, we check if the first two characters of the name are both upper case and if so leave it alone. So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”
But "if the first two characters of the name are both upper case" doesn't apply here.
What am I missing?