• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat 4.0.1 - javabeans not found  RSS feed

 
Francois Bourgault
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
When I run a jsp page, I get the following:
An error occurred at line: 19 in the jsp file: /list_guests.jsp
Generated servlet error:
C:\Apache\jakarta-tomcat\work\localhost\Src\list_0005fguests$jsp.java:91: Class org.apache.jsp.Guest_Bean not found.
formhandler = (Guest_Bean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "Guest_Bean");
The class file is in: myServlets\web-inf\classes\Guest_Bean.class
FYI: I can run jsp files without javabeans.
I looked at my classpath and everything seems ok.
Also, the bean is registered in web.xml
Where should I move the class file?
Any help would be appreciated,
Francois.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like a packaging problem. If you don't place your JavaBeans (and tags for that matter) in a package then the JSP implementation can have problems locating them.
Are your Java classes in a package?
Cheers
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed. The message org.apache.jsp.Guest_Bean not found says it all, doesn't it? I bet this is not the package you put the bean in, but it is where the compiler is expecting your class to be in. It must be the package Tomcat compiles the JSP into. And a JSP is, ultimately, just another Java class, behaving like any class in the org.apache.jsp package would do.
The default package is nice if you quickly want to try something out with one or two self-contained classes. Otherwise it's a language feature best left unused.
- Peter
 
Francois Bourgault
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all,
I use the following code to specify the package:
<%@ page language="java" import="java.sql.*, myServlets.web-inf.classes" %>
And I get this error:
org.apache.jasper.JasperException: Unable to compile class for JSP
C:\Apache\jakarta-tomcat\work\localhost\Src\list_0005fguests$jsp.java:4: ';' expected.
import myServlets.WEB-INF.classes;
^
How do I get around this?
The reason I don't want to specify a package is that I will be moving the code to a ISP. Who knows what will be the setup on their side. I try to make it as generic as possible.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!