• 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

problem with TOMCAT_HOME configration

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
jimmy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

tryied without any luck.


Tried what, to compile, or run it?
 
jimmy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
================================

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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like servlet-api.jar is not in your classpath.
Check your classpath for typing errors.

echo %CLASSPATH%
 
jimmy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic