aspose file tools*
The moose likes Servlets and the fly likes Bean found at compile but not runtime. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Bean found at compile but not runtime." Watch "Bean found at compile but not runtime." New topic
Author

Bean found at compile but not runtime.

Michael Mendelson
Ranch Hand

Joined: Dec 19, 2000
Posts: 73

I have a jsp which uses a bean. The JSP compiles, but can't find the Bean at runtime. I'm using Tomcat. Perhaps there's a classpath setting that I'm missing, or something?
The jsp is located in d:\java\dev\bg (mapped to localhost\bg)
The Bean (GreenBean) is in package com.intown.bg.beans.
Its class file is located in d:\java\dev\bg\WEB-INF\class\com\intown\bg\beans.

At runtime, I get a "500" error ( javax.servlet.ServletException: Cannot create bean of class GreenBean )
I would appreciate any suggestions.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
You must give the complete package when naming the class in the useBean tag in addition to importing it. Instead of:
class="GreenBean" />
use
class="com.intown.bg.beans.GreenBean" />
Not every JSP engine seems to require this but Tomcat does.
Bill

------------------
author of:
Michael Mendelson
Ranch Hand

Joined: Dec 19, 2000
Posts: 73
Thanks William, that worked.
However, now I'm having the problem that Tomcat does not find some jar files that are present in my development environment. How do I set the classpath there?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
Tomcat expects to find jar files for a "web application" in a very specific location based on WEB-INF, just like servlet class files.
WEB-INF
+-- classes/ class files go here
+-- lib/ jar files go here
OR if the jar is used by more than one application
tomcat/lib is the place for them.
Tomcat uses specialized loaders for classes, so don't depend on your CLASSPATH environment variable.
Michael Mendelson
Ranch Hand

Joined: Dec 19, 2000
Posts: 73
Thanks, Bill.
That's the problem. In my development environment I have my "general utilities" library in another place.

[This message has been edited by Michael Mendelson (edited February 24, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bean found at compile but not runtime.