1

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:

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?

Community
  • 1
  • 1
Marcel Stör
  • 22,695
  • 19
  • 92
  • 198

1 Answers1

1

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?

The "existing Java name" of your method is "getXAxis", or it could be "isXAxis" for a boolean property.

The "middle of an existing Java name" is "XAxis". The "first two characters" of that are "XA", so that is left as is, without decapitalization.

There is a way to explicitly map method names onto a property name with an explicit BeanInfo, but it is rarely used.

BTW, the JavaBeans 1.01 specification is dated August 1997. It is actively used for 18 years. Download page: http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html

Konstantin Kolinko
  • 3,854
  • 1
  • 13
  • 21
  • Thanks, I failed to see that `name` in `decapitalize(String name)` is the accessor method name, I thought it'd be the property name. – Marcel Stör May 07 '15 at 07:30