Unable to locate bean class in Tomcat 6.0

I'm sorry if this has been answered before but any topic I found related to this would not provide an answer that would work for me.

This is the error I received:

org.apache.jasper.JasperException: /dariend/web/SaveName.jsp(1,1) The value for the useBean class attribute user.UserData is invalid.

org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)

org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)

org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)

org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)

org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)

org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)

org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)

org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)

org.apache.jasper.compiler.Node$Root.accept(Node.java:489)

org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)

org.apache.jasper.compiler.Generator.generate(Generator.java:3374)

org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)

javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

And this is the hierarchy of my webapp (in the ROOT directory):

src--user--UserData.java

|

dariend

|

web (All HTML and JSP files here)--WEB-INF--classes--user--UserData.class

In SaveName.jsp (in the web directory) I have the following tag:

<jsp:useBean id="user" class="user.UserData" scope="session"/>

[2168 byte] By [Darienda] at [2007-11-27 8:41:22]
# 1

Standard reasons for getting this message

1 - Your class is not compiled correctly, or is not in the correct place. Recompile the class. Make sure it is in the [webroot]/WEB-INF/classes directory in its appropriate package

2 - Class is not in a package (n/a here - seems to be in a package)

3 - Class does not have a public constructor that takes no arguments.

JSP being invoked: /dariend/web/SaveName.jsp(1,1)

>And this is the hierarchy of my webapp (in the ROOT directory):

I think this is the issue.

1 - WEB-INF must be in the root directory of your web application

2 - ROOT directory is the "default" web app (web app with a context of "") Not the root of where you put your web apps.

If you are going to use the ROOT webapp, your directory structure should be

[TOMCAT]webapps/ROOT/WEB-INF/classes/user/UserData.class

It is generally the case that you don't use the ROOT web app, and instead deploy each app into its own context.

In that case

[TOMCAT]/webapps/myWebApp/WEB-INF/classes/user/UserData.class

and

[TOMCAT]/webapps/myWebApp/web/saveName.jsp

You would then access http://localhost:8080/myWebApp/web/saveName.jsp

Hope this helps,

evnafets

evnafetsa at 2007-7-12 20:40:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
THANK YOU!!! IT WORKED!I put the 'dariend' directory into the 'webapps' directory and put the 'WEB-INF' inside the 'dariend' directory and it worked :)Thanks!Bradley RiethDariend
Darienda at 2007-7-12 20:40:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...