File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bean found at compile but not runtime.

 
Michael Mendelson
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic