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.
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
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?
Author and all-around good cowpoke
Joined: Mar 22, 2000
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.
Joined: Dec 19, 2000
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).]