• 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 not created...

 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use a bean in a jsp, but I receive the message:

I am running Tomcat 3.somethingOrOther. I have Servlets and JSPs working fine. I have the Bean class compiled and in the /WEB-INF/classes directory of my WebApp directory. The Bean is not in a package.
According to the Java Tutorial JavaBeans Trail, in order to be a Bean the class must implement Serializable, but Marty Hall's Core book never mentions it. Regardless, it does not work either way for me.
JSP useBean code:

Bean class code:


I have the getXxx() methods, I've implemented Serializable, all the variables are private. I don't know why else it could not create the Bean...
TIA
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joel, do a search through this site. I'm fairly certain I recall seeing a number of disucssion of problems caused by "package-less" beans, though I don't remember the details off the top of my head.
Short of that, place your bean in a package (which is goodness and apple pie) and your problem may go away on its own.
hth,
bear
 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I put my bean in a package.
First, I put the package in the /lib directory but got an error saying that it could not find the package.
So I moved the package to the /classes directory and it must have found it, but now I'm back to the original problem...


javax.servlet.ServletException: Cannot create bean of class ClientListBean


There must be something wrong with ClientListBean, but I can't see what it is...
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So your class hierarchy is set up something along the lines of:
WEB-INF/classes/mypackage/ClientListBean.class
(and yes, classes/ is the right place for this; if you pack up your classes into a jar, then the jar is what you would put into lib/)
and your useBean directive is something like:
jsp:useBean id="whatever" class="mypackage.ClientListBean" scope="request"
Correct?
bear
 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arrrgggghhhhhh....
I forgot to add the "myPackage.xxx" to my useBean statement. Once I did that, it worked fine!
Thanks Bear, most appreciated!
 
Your mind is under my control .... your will is now mine .... read this 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