Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Package not found in import problem

Status
Not open for further replies.

JohnBoyW

Programmer
Sep 20, 2002
2
US
Package xxxx not found in import.

A common error I'm sure, but it has taken me hours to try and sort it out, to no avail.

Can anyone help with this error please?

1/ I placed file P6.jsp in directory webapps\lab06
2/ I placed file NameStore.class in directory webapps\Lab06\web-inf\classes\MyUtils
3/ Using Tomcat I opened my .jsp file in the browser using URL
4/ The P6.jsp file was found, but my class file NameStore.class in package MyUtils was not found. This was the error shown in my browser:-
----------------------------------------------------------------------------------------------

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.

C:\jdk1.4\jakarta-tomcat-4.0.1\work\Standalone\localhost\lab06\P6$jsp.java:3: Package MyUtils not found in import.

import MyUtils.* ;
^

----------------------------------------------------------------------------------------------


My current directory set up is:-

webapps--lab06( contains P6.jsp)
|
|
|
|
|
|
--- web-inf
|
|
-----classes
|
|
|
------MyUtils (contains NameStore.class)




----------------------------------------------------------------------------------------------


My P6.jsp code starts with :-

<HTML>
<HEAD>
<TITLE>P6.jsp</TITLE>
</HEAD>
<BODY>

<%@page import=&quot;MyUtils.* ,java.util.*&quot;%>
...
----------------------------------------------------------------------------------------------


The source file for my Namestore class, i.e NameStore.java
code starts with:-

package MyUtils;

import java.util.*;

public class NameStore {...
----------------------------------------------------------------------------------------------


thanks,

John Withington
 
I am having the same problem. Have you found a solution yet?
 
Hi theBorg, no I have not unfortunately a solution to this problem yet. It seems so fundamental the answer must be simple but it has been a problem for me for 11 days now! I have put two posts on the Sun JSP forum as well, but no-one has replied. My Java teacher has not come up with a solution either, he said yes the structure has to be of the type:
Code:
/webapps/myapp( contains .jsp file)/web-inf/classes/MyUtils/NameStore.class
,where MyUtils is the package name
(first statement in the NameStore.class, NameStore is used by the .jsp code in MyUtils directory)

I can only assume that as no-one has replied with a solution that this structure is correct and most people get along fine with it. I wonder if the classpath may be the problem and if there is a way of seeing where(which directories) the .jsp is looking for the class at translation time?

I'll post an answer to this forum if I get one.

John
 
I had a similar problem with JBossWeb. Cleaning up the tmp directory helped solve the problem.

For JBossWeb,
Stop the service.
Delete the contents of JOBSS_HOME/tmp.
Start the service.

A similar directory may exist (I guess it is called 'work')for tomcat. Cleaning this may help.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top