tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Lynn Rice" <dr...@dmotorworks.com>
Subject RE: getting error message "Cannot create bean of class beanProperties"
Date Tue, 25 Jul 2000 01:35:04 GMT
	My actual example is in a package and I do specify the full package in the
useBean declaration, but it still has the problem of getting the "Cannot
create bean of class beanProperties" error message.

	If there is a better way to implement something like Properties in java, I
would be more than willing to explore an alternative implementation.

~David


-----Original Message-----
From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
Sent: Monday, July 24, 2000 8:21 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: getting error message "Cannot create bean of class
beanProperties"


David Lynn Rice wrote:

> ########## Environment
> Tomcat: 3.1 SunJDK: 1.2.2 Linux
>
> I am trying to implement an interface that contains some global strings in
a
> very simple interface:
>
> public interface Properties {
>         public static final String FOO_INFORMATION = "Information";
> }
>
> I use this interface to give static String properties to several classes
and
> servlets, but I also need to be able to get to these Properties from a
jsp.
> And, in order to use it in a jsp, I implement a dummy class like this (it
is
> in WEB-INF classes):
>
> public class beanProperties implements Properties { }
>
> This way I can instantiate the beanProperties object and access these
> strings using something like this:
>
> <jsp:useBean id="prop" scope="page" class="beanProperties" />
>
> and
>
> <%= prop.FOO_INFORMATION %>
>
> ########## Problem
>
> If I recompile ANY classes, then I get a ServletException that says
"Cannot
> create bean of class beanProperties"
>
> It looks like the Jasper engine generates the following piece of code:
>         try {
>                 prop = (beanProperties)
Beans.instantiate(getClassLoader(),
> "beanProperties");
>         } catch (Exception exc) {
>                 throw new ServletException (" Cannot create bean of class
> "+"beanProperties\n");
>         }
>
> and according to the API instantiate can either return a IOException or a
> ClassNotFoundException, but I can't tell what type of exception is being
> thrown.
>
> Basically, I cannot figure out why this is happening, but it is preventing
> me from using the Class reloading feature because I end up restarting
tomcat
> everytime I recompile anything.
>

The generated code shown above has been modified to include the "exc"
exception
as a second argument to the ServletException constructor (in the current
development code base, but not yet folded into a beta for Tomcat 3.2),
so you
will a least be able to see what underlying exception was thrown.  It
will be
logged as the "root cause" of this exception in Tomcat's logs.

One problem you will have is that your "beanProperties" class appears
not to be
in a package.  This causes problems because the "default" package
codebase
varies with where the JSP page itself is.  A solution would be to define
this
class in a package, and declare the fully qualified classname in the
<jsp:useBean> declaration.

>
> ~David

Craig McClanahan


Mime
View raw message