wood burning stoves 2.0*
The moose likes Tomcat and the fly likes problem with TOMCAT_HOME configration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "problem with TOMCAT_HOME configration" Watch "problem with TOMCAT_HOME configration" New topic
Author

problem with TOMCAT_HOME configration

jimmy
Greenhorn

Joined: Sep 01, 2004
Posts: 17
Hi,

when i try to run a small servlet programe i get the following error:
================================

C:\Program Files\Apache Software Foundation\Tomcat 5.5\project1\src>javac Ch1Ser
vlet.java
Ch1Servlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
Ch1Servlet.java:2: package javax.servlet does not exist
import javax.servlet.http;
^
Ch1Servlet.java:3: package javax.io does not exist
import javax.io.*;
^
Ch1Servlet.java:5: cannot find symbol
symbol: class HttpServlet
public class Ch1Servlet extends HttpServlet {
^
Ch1Servlet.java:6: cannot find symbol
symbol : class HttpServletRequest
location: class Ch1Servlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws IOExpection {
^
Ch1Servlet.java:6: cannot find symbol
symbol : class HttpServletResponse
location: class Ch1Servlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws IOExpection {
^
Ch1Servlet.java:6: cannot find symbol
symbol : class IOExpection
location: class Ch1Servlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws IOExpection {

^
Ch1Servlet.java:8: cannot find symbol
symbol : class PrintWriter
=========================================

I am gussing this error is bec i have not set the TOMCAT_HOME path.
I just installed tomcat from site and started using it ,, but i get the tomcat home page when i write http://localhost:8080/

Please help.
Thanks.
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
I think you're missing some important parts to servlet development. The first thing you will need to do is compile your servlet. This will require you to have, in Tomcat, servlet.jar (Tomcat 4.x) or servlet-api.jar (Tomcat 5.x) on your class path.

Once you have a compiled servlet it needs to be put into a web application and can then be run.

I'd encourage you to look the documentation for Tomcat. If you have Tomcat installed and running (which it sounds like you do) then you should see a link on the page for Tomcat Documentation. Otherwise, online you'll want to look at the Tomcat docs.


<a href="http://forums.hotjoe.com/forums/list.page" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
jimmy
Greenhorn

Joined: Sep 01, 2004
Posts: 17
Hi Scott,

for me the filr 'servlet-api.jar ' was in 'C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib'.
And so i copied the full path 'C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar' in the classpath and then tryied without any luck.

I also tryed to see the documentation given ,, but didnt help me.

Please help me. i am just not able to proceed further.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

tryied without any luck.

Tried what, to compile, or run it?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
jimmy
Greenhorn

Joined: Sep 01, 2004
Posts: 17
================================

C:\Program Files\Apache Software Foundation\Tomcat 5.5\project1\src>javac Ch1Ser
vlet.java
Ch1Servlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
Ch1Servlet.java:2: package javax.servlet does not exist
import javax.servlet.http;
^
Ch1Servlet.java:3: package javax.io does not exist
import javax.io.*;
^
Ch1Servlet.java:5: cannot find symbol
symbol: class HttpServlet
public class Ch1Servlet extends HttpServlet {
^
Ch1Servlet.java:6: cannot find symbol
symbol : class HttpServletRequest
location: class Ch1Servlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws IOExpection {
^
Ch1Servlet.java:6: cannot find symbol
symbol : class HttpServletResponse
location: class Ch1Servlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws IOExpection {
^
Ch1Servlet.java:6: cannot find symbol
symbol : class IOExpection
location: class Ch1Servlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws IOExpection {

^
Ch1Servlet.java:8: cannot find symbol
symbol : class PrintWriter
=========================================
jimmy
Greenhorn

Joined: Sep 01, 2004
Posts: 17
HI ben,

i get the above pasted error when i try to complie the servlet program.

I guess this is bec it is not able to find javax files ,,

Please help.
Thanks for your time.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

It sounds like servlet-api.jar is not in your classpath.
Check your classpath for typing errors.

echo %CLASSPATH%
jimmy
Greenhorn

Joined: Sep 01, 2004
Posts: 17
Hi ben,

Now i am able to compile the first servlet program and see the results( current date in the brower ,, i am following the HFSJ book)

bUT When doing hte second eg ,, i am able to compli the servlet but when i call the servlet from the html ,,it gives the following error:


HTTP Status 500 -

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

type Exception report

message
description The server encountered an internal error () that prevented it from fulfilling this request.

Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Look in your tomcat logs for the stack trace.
Starting from the top of the trace, look down each line until you see your servlet class listed. It will give you a line number where the error occured.
It will also tell you what kind of exception was thrown.

Tomcat's logs are located in a directory named 'logs' just under the directory where Tomcat was installed. Depending on your installation and OS the specific name of the log file may vary.

Look through all of them.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with TOMCAT_HOME configration