aspose file tools*
The moose likes Beginning Java and the fly likes Class path issue? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Class path issue?" Watch "Class path issue?" New topic
Author

Class path issue?

sidd jain
Greenhorn

Joined: Jun 22, 2009
Posts: 4
I'm new to tomcat and JSP programming. Anyway, I received a project and am trying to run it. As far as I know, all the required files are there but I guess java can't find them. All the project files are stored in the Tomcat webapps folder. When I open a file for example in IE, I get a bunch of errors similar to:



(the [***] are inserted to mask the actual file names)

So my issue is how do I get Tomcat to access the relevant java files so that it actually runs. I tried putting the file names in the Classpath, but I am assuming I did it wrong since ther error is still there. I know the code works because there is a copy of the project running on a server and it operates completely fine without any errors so clearly it is just the configuration here that is wrong.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

Sounds more like a missing import problem.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
sidd jain
Greenhorn

Joined: Jun 22, 2009
Posts: 4
Perhaps, but as I say it does work on the online version so the code itself does not have any problems. If there were missing imports I would think that it would not work online either.

Either way, I don't see how to solve that since the files are imported by the jsp file:


So, what should I do?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

What is the exact directory structure for the web app? Are the missing classes in packages? What do the imports really look like (put fake names if you want, but make them as close as possible to the real thing)? What versions of the Tomcat on the online version? The local Tomcat version?


Steve
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What do you mean, the "online version"? Are you saying it can't find java.text.*, or whatever the "***" imports are?

If it can't find the "***" imports then the "***" imports aren't in /WEB-INF/lib. (Or in the container classpath, but if they're your own libs it's almost certain that they belong in /WEB-INF/lib.)
sidd jain
Greenhorn

Joined: Jun 22, 2009
Posts: 4
I am using apache-tomcat-6.0.18. As previously mentioned, I received this directory of files that are operating fine on an online server. I am not sure what version the server was using.

I will now attempt to explain the file structure. The .jsp files are stored in the C:\apache-tomcat-6.0.18\webapps\ROOT\prob directory. The java files were originally stored in directories similar to C:\apache-tomcat-6.0.18\webapps\ROOT\prob\src\com\cool\next\trans\db . After reading your reponse I copied them to C:\apache-tomcat-6.0.18\webapps\ROOT\WEB-INF\lib\com\cool\next\trans\db . That did not solve the problem.

The import in the .jsp file is as so:

The are many .jsp files and many more files that are being imported but I think this one gives an example of the problem that seems to be the same along the different files.
The error seen in IE when viewing the JSP file is similar to this:

I'm quite confused as to what is causing this issue since I know that these .JSP files operate fine on the server. They are used on our intranet for internal customers strictly and therefore I am unable to share the exact code and my liberty in using the exact names is quite limited. But I will try to give you the most I can to help you get an understanding of my situation.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

sidd jain wrote:I am using apache-tomcat-6.0.18. As previously mentioned, I received this directory of files that are operating fine on an online server. I am not sure what version the server was using.

I will now attempt to explain the file structure. The .jsp files are stored in the C:\apache-tomcat-6.0.18\webapps\ROOT\prob directory. The java files were originally stored in directories similar to C:\apache-tomcat-6.0.18\webapps\ROOT\prob\src\com\cool\next\trans\db . After reading your reponse I copied them to C:\apache-tomcat-6.0.18\webapps\ROOT\WEB-INF\lib\com\cool\next\trans\db . That did not solve the problem.
[/code]

That should be:
C:\apache-tomcat-6.0.18\webapps\ROOT\WEB-INF\classes\com\cool\next\trans\db

Put packaged JAR files in WEB-INF/lib. Put loose classes in WEB-INF/classes.

And make sure it is the .class files that go there, not .java files.
sidd jain
Greenhorn

Joined: Jun 22, 2009
Posts: 4
Thanks a lot for your help
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Class path issue?