tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: getting error message "Cannot create bean of class beanProperties"
Date Tue, 25 Jul 2000 01:20:30 GMT
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"
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
varies with where the JSP page itself is.  A solution would be to define
class in a package, and declare the fully qualified classname in the
<jsp:useBean> declaration.

> ~David

Craig McClanahan

View raw message