You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by S Ramakrishnan <rk...@lycos.com> on 2001/08/21 02:51:59 UTC

TCb7 can't find my application specific classes

Env:
  Tomcat b7 standalone, Windows 2000

Problem:
  I find that Tomcat ends up looking for my application
classes under the prefix org.apache.jsp. For instance,
I have a class under webapps\brcat\WEB-INF\classes\Banner.class.
The JSP that refers to this bean gets a compilation error:

 "
 An error occurred at line: 3 in the jsp file: /login.jsp

 Generated servlet error:
 C:\tc\work\localhost\brcat\_0002flogin_jsp.java:60: Class  org.apache.jsp.Banner not found.
                Banner banner = null;
 "
                

Is there a parameter in the context where I should
set the classpath? Isn't the classpath for
my context automatically include webapps\brcat\WEB-INF\classes?

My context for the application is as follows:

      <Context path="/brcat" docBase="brcat" debug="1"
               reloadable="true">
    <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
        <Logger className="org.apache.catalina.logger.FileLogger"
                   prefix="rks_log." suffix=".txt"
                timestamp="true"/>
      </Context>
 

/Kobe



Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/

Re: TCb7 can't find my application specific classes

Posted by "Pier P. Fumagalli" <pi...@betaversion.org>.
S Ramakrishnan at rk_@lycos.com wrote:

> Env:
> Tomcat b7 standalone, Windows 2000
> 
> Problem:
> I find that Tomcat ends up looking for my application
> classes under the prefix org.apache.jsp. For instance,
> I have a class under webapps\brcat\WEB-INF\classes\Banner.class.
> The JSP that refers to this bean gets a compilation error:
> 
> "
> An error occurred at line: 3 in the jsp file: /login.jsp
> 
> Generated servlet error:
> C:\tc\work\localhost\brcat\_0002flogin_jsp.java:60: Class
> org.apache.jsp.Banner not found.
>               Banner banner = null;
> "

Put your Banner.class into a package, and import it from the JSP...

    Pier


Re: TCb7 can't find my application specific classes

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Mon, 20 Aug 2001, S Ramakrishnan wrote:

> Env:
>   Tomcat b7 standalone, Windows 2000
> 
> Problem:
>   I find that Tomcat ends up looking for my application
> classes under the prefix org.apache.jsp. For instance,
> I have a class under webapps\brcat\WEB-INF\classes\Banner.class.
> The JSP that refers to this bean gets a compilation error:
> 

The JSP spec allows an implementation to put the generated classes for
your pages into any Java package it wants to -- Tomcat uses
"org.apache.jsp" for this purpose.

Now, if you think about what the Java compiler does, the problem will
become more understandable -- references to a Java class that have no
package name, and are not listed in an "import" directive, are assumed to
be in the same package as the class being compiled (the generated servlet
for your JSP page, in this case).

>  "
>  An error occurred at line: 3 in the jsp file: /login.jsp
> 
>  Generated servlet error:
>  C:\tc\work\localhost\brcat\_0002flogin_jsp.java:60: Class  org.apache.jsp.Banner not found.
>                 Banner banner = null;
>  "
>                 
> 
> Is there a parameter in the context where I should
> set the classpath? Isn't the classpath for
> my context automatically include webapps\brcat\WEB-INF\classes?
> 

No, but that is not the problem anyway.

It appears that you are using a bean class that is not in a package
(i.e. there's no "package" declaration at the top).  In order to use such
a bean class in a JSP page, you *must* import it in a <%@ page %>
directive:

  <%@ page import="Banner" ... %>

so that you can use it in things like <jsp:useBean>.  Alternatively, you
can declare your bean inside a package, and use the fully qualified class
name in <jsp:useBean>, and everything will also work fine.  (That is
actually the recommended course of action, because then there is never
any confusion about what package the class is part of.)

Craig McClanahan