• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bean found at compile but not runtime.

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic