• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bean not created...

 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!