DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13206>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13206

Invalid java bean property error message could be reported better.

           Summary: Invalid java bean property error message could be
                    reported better.
           Product: Tomcat 4
           Version: 4.0.4 Final
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Jasper
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Using an invalid Java bean that has setXXX and getXXX property methods that 
have different in and out types can be difficult to track down. The error 
message returned in such a case could be improved by including the property 
type.

For example:

public class MyBeanClass {
  MyViewClass mvc;

  public void setView(String myViewClass) {
    try {
      mvc = (MyViewClass)Class.forName(myViewClass).newInstance();
    } catch(Exception ex) {}
  }

  public MyViewClass getView() {
    return myViewClass;
  }
}

The problem with this java bean class is that the property 'view' has two 
different types i.e. set takes a String but the get returns a MyViewClass 
object.

If we use the following code in a JSP:-

<jsp:useBean id="myBean" class="MyBeanClass" scope="application">
  <jsp:setProperty name="myBean" property="view" value="MyViewClass"/>
</jsp:useBean>

the following exception is thrown:-

org.apache.jasper.JasperException: Can't find a method to write property 'view' 
in a bean of type 'MyBeanClass'
    at org.apache.jasper.runtime.JspRuntimeLibrary.internalIntrospecthelper
(JspRuntimeLibrary.java)
    at org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper
(JspRuntimeLibrary.java)
    at org.apache.jsp.myJSP$jsp._jspService(myJSP$jsp.java)

If the type of the propery was printed out in the error message this would make 
this mistake a lot easier to track down.

See line 714 in org.apache.jasper.runtime.JspRuntimeLibrary

private static void internalIntrospecthelper(Object bean, ...) ... {
  ...

  if(type == null)
    throw new JasperException(
          Constants.getString("jsp.error.beans.noproperty", 
            new Object[] { prop, bean.getClass().getName() 
          }));
  else
    throw new JasperException(
          Constants.getString("jsp.error.beans.nomethod.setproperty",
            new Object[] { prop, bean.getClass().getName()
          }));
  ...
}

The else part of the above code is been excecuted and even that the 'type' is 
found it is not inserted into the exception.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to