• 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

Package...not found in import

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic