File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Package...not found in import Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Package...not found in import" Watch "Package...not found in import" New topic
Author

Package...not found in import

Tokunbo Oke
Ranch Hand

Joined: Sep 09, 2003
Posts: 57
I am using Tomcat 4.0 on windows 98, when I try to use my bean class from jsp program, I get package not found error. I read/followed all the similar problems in the forum but still have not been able to solve the problem.
The error I get is as follows:
==============================
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
D:\Apps\Apache\Tomcat4.0\work\Standalone\localhost\cartapp\handoff1$jsp.java:3: Package com.cartapp.user not found in import.
import com.cartapp.user.*;
^
1 error, 1 warning
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
Location of files
==================
My jsp file is located at:
D:\Apps\Apache\Tomcat4.0\webapps\ROOT\WEB-INF\com\cartapp
my bean class - User - is at:
D:\Apps\Apache\Tomcat4.0\webapps\ROOT\WEB-INF\com\cartapp\user
Contents of the jsp file
=======================
<jsp:useBean id="handoff" scope="session" class="com.cartapp.user.User" />
<HTML>
<BODY>
This is the setting page!
<%
handoff.setFirstName("George");
%>
</BODY>
</HTML>
First line of bean class
========================
package com.cartapp.user;
Environment settings
====================
JAVA_HOME=D:\Apps\java\jdk
CATALINA_HOME=D:\Apps\Apache\Tomcat4.0
CLASSPATH=;.;F:\ola\progmn\JAVA\pkgs;D:\Apps\Apache\Tomcat4.0\common\lib\servlet.jar;D:\Apps\Apache\Tomcat4.0\webapps\ROOT\WEB-INF\classes
Can anyone please help, this is driving me mad. Thanks.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
You'll get better Tomcat help in the Tomcat forum, so I'm moving this post there.
Btw, you win 2 gold stars for an exemplary question - specific, to the point, with all the necessary information for people to provide the best level of help. I'm rushed right now so I can't research your question, but if no one has answered by noon today I'll take a shot at it myself.


Rob
SCJP 1.4
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
my bean class - User - is at:
D:\Apps\Apache\Tomcat4.0\webapps\ROOT\WEB-INF\com\cartapp\user

I think you want to put your user class in:
D:\Apps\Apache\Tomcat4.0\webapps\ROOT\WEB-INF\classes\com\cartapp\user
Also, you don't need to have the "..\Tomcat\.." directories in your classpath when running Tomcat: it will automatically discover and add everything it needs to the classpath.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Also, don't put the JSP in the Web-INF directory. It should be one level higher, so you want to put it in this directory:
D:\Apps\Apache\Tomcat4.0\webapps\ROOT
Tokunbo Oke
Ranch Hand

Joined: Sep 09, 2003
Posts: 57
Rob,
Thanks for your response.
Further to your recommendations, I did the following:
1. Moved the User class to D:\Apps\Apache\Tomcat4.0\webapps\ROOT\WEB-INF\classes\com\cartapp\user
2. changed my classpath to CLASSPATH=;.;F:\ola\progmn\JAVA\pkgs;D:\Apps\Apache\Tomcat4.0\common\lib\servlet.jar
3. Moved my jsp to D:\Apps\Apache\Tomcat4.0\webapps\ROOT\cartapp. In addition I changed the context to this directory in the SERVER.XML file.
After restarting the computer, I got this error (class not found):
===========================================
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.

An error occurred at line: 1 in the jsp file: /handoff1.jsp
Generated servlet error:
D:\Apps\Apache\Tomcat4.0\work\Standalone\localhost\cartapp\handoff1$jsp.java:56: Class com.cartapp.user.User not found.
com.cartapp.user.User handoff = null;
^

An error occurred at line: 1 in the jsp file: /handoff1.jsp
Generated servlet error:
D:\Apps\Apache\Tomcat4.0\work\Standalone\localhost\cartapp\handoff1$jsp.java:59: Class com.cartapp.user.User not found.
handoff= (com.cartapp.user.User)
^

An error occurred at line: 1 in the jsp file: /handoff1.jsp
Generated servlet error:
D:\Apps\Apache\Tomcat4.0\work\Standalone\localhost\cartapp\handoff1$jsp.java:64: Class com.cartapp.user.User not found.
handoff = (com.cartapp.user.User) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "com.cartapp.user.User");
^
3 errors, 1 warning
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
=============================================

The first 2 lines of the class are:
==================================
package com.cartapp.user;
public class User {

Thanks.
Ola Oke (SCJP 1.4)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package...not found in import