You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2001/10/08 15:23:27 UTC
DO NOT REPLY [Bug 4021] New: -
useBean with only class and scope attributes specified, will result in a fatal translation error if the class is abstrace, an interface, or a class without a public no-arg constructor.
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=4021>.
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=4021
useBean with only class and scope attributes specified, will result in a fatal translation error if the class is abstrace, an interface, or a class without a public no-arg constructor.
Summary: useBean with only class and scope attributes specified,
will result in a fatal translation error if the class is
abstrace, an interface, or a class without a public no-
arg constructor.
Product: Tomcat 4
Version: 4.0 Final
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: Jasper
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: Ryan.Lubke@Sun.COM
According to JavaServer Pages Specification 1.2 Section JSP.4.1 page 71,
"5. if the object is not found in the specified scope and the class specifies a
non-abstract class that defines a public no-args constructor, then the class is
instantiated....
If the object is not found, and the class is either abstract, an interface, or
no public no-args constructor is defined therein, then a
java.lang.InstantiationException shall occur...."
Simple test case:
**********************************************************************
<html>
<title>InstantiationException Test</title>
<body>
<% try { %>
jsp:useBean id="abstractBean" class="test.AbstractBean" scope="page" />
<% catch ( java.lang.InstantiationException ie ) {
out.println( "InstantiationException caught! Test Status: PASS" );
}
%>
</body>
</html>
*************************************************************
The AbstractBean class is nothing more than a simple abstract class.
When the JSP is called, instead of the InstantiationException being caught,
a fatal translation error occurs stating that java.lang.InstantiationException
is not thrown by the corresponding try block.
The generated source for the JSP looks something like this:
try {
abstractBean =
(core_syntax.actions.useBean.AbstractBean)
java.beans.Beans.instantiate(this.getClass().getClassLoader(),
"core_syntax.actions.useBean.AbstractBean");
} catch (Exception exc) {
throw new ServletException (" Cannot create bean of
class "+"core_syntax.actions.useBean.AbstractBean", exc);
}
The catch block here should be throwing java.lang.InstantiationException and not
ServletException.