• 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

Configuring Tomcat...

 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am finding trouble with the tomcat installations and running servlets on it. Here is what I have done...
1. Installed latest J2SE 5.0 update 6 on "D:\Java"
2. Installed latest version of Tomcat 5.5.12 on "D:\Tomcat\"
3. Set these variables as follows....

4. Unzipped the servlet classfiles in lib directory of "d:\java\lib"

After all this....

1. I type "javac" on the command line and it works fine. (Java environment variable is ok)

2. When I start the tomcat, the default page... http://localhost:8080/ is displayed. if I stop tomcat I am not able to view it. (Server is OK)

3. I am able to compile a servlet file.. HelloServlet.java and get a class file HelloServlet.class file (Servlets are compiled)

4. The examples that come bundled with "D:\Tomcat\webapps\servlets-examples" are working properly in Tomcat.

BUT....

1. I created a new directory... by name "myAPP" in "D:\Tomcat\webapps"
and I have... "D:\Tomcat\webapps\myAPP". Under this I created one more folder "WEB-INF\classes" and dumped my servlets there.

2. Copy pasted a "web.xml" with following contents in it...



And the servlet doesnt run in tomcat... ( This is the first step and I am bugged up with this, I know the preconfigured version at coreservlets.com works fine. But I want to configure things by myself. Moreover i can dump my servlets into "servlets-examples" folder itslef, but I want "myAPP" to run properly.... awaiting for your suggestions. Thanks in advance.

[ December 20, 2005: Message edited by: Akhil Trivedi ]
[ December 20, 2005: Message edited by: Akhil Trivedi ]
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you configure the "Servlet-api.jar" in class path. If not then do so.

Thanks
Chidanand Chauhan
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I configure that... I guess that is equal to copy-pasting the content of servlet.jar into "lib" folder of java. Isn't it?? If no.. then how do I configure that??

If that is the problem, should my servlets compile?? plz help..
[ December 20, 2005: Message edited by: Akhil Trivedi ]
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think, it is because, you forgot to add servlet-mapping tag:

 
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
Moved to the Apache Tomcat forum
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chidanand Chauhan:
Have you configure the "Servlet-api.jar" in class path. If not then do so.

Thanks
Chidanand Chauhan



Why?

It came by default in tomcat/common/lib directory.

[ December 20, 2005: Message edited by: rathi ji ]
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am beginner here...
Isn't the mapping tag optional??
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java_home --- d:\java\bin;d:\java\lib;d:\java;
classpath --- d:\java\bin;d:\java\lib;d:\java;
catalina_home --- D:\Tomcat\
path --- d:\java\bin;d:\java\lib;d:\java;D:\Tomcat\webapps\myApp;



There are multiple problems here:
- JAVA_HOME must be exactly one directory, not several. In your case d:\java
- CLASSPATH enumerates classes, but neither bin nor lib nor d:\java contains any. Jar files need to be specifically mentioned in the classpath in order to be picked up.
- PATH is for executables. Ther are none in lib nor in d:\java nor in your web apps directory (I hope)
Try to develop a solid understanding what PATH does and what CLASSPATH does.

The servlet mapping is not optional. It would be kind of unusual to map to *.do, though, because that's generally used by Struts, not straight servlets as you have here.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf! I do understand the stuff... but do you think redundancy is gonna cause me problems. Well, i have taken off the unnecessary things here and i am still not out of my problem... servlets get compiled but dont run in a new folder... how do I configure my new folder and let tomcat accept it, without having to copy paste my class file and dump them in default "servlets-examples" folder??
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does "it doesn't run" mean? What happens when you hit http://localhost:8080/myApp/Hello (assuming you have mapped "Hello" to your servlet)? What do the <servlet> and <servlet-mapping> elements in your web.xml look like?
 
Chidanand Chauhan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rathi ji:


Why?

It came by default in tomcat/common/lib directory.


[ December 20, 2005: Message edited by: rathi ji ]



you have to explicitly mention classpath
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the content of my web.xml fine that lies in.. "D:\Tomcat\webapps\myApp\WEB-INF" directory



http://localhost:8080/myApp/servlet/HelloServlet
and
http://localhost:8080/myApp/HelloServlet

both

Shows...

HTTP Status 404 - /myApp/servlet/HelloWorld ( or /myApp/HelloWorld)
type Status report

message /myApp/servlet/HelloWorld

description The requested resource (/myApp/servlet/HelloWorld) is not available.
Apache Tomcat/5.5.12
[ December 20, 2005: Message edited by: Akhil Trivedi ]
 
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


http://localhost:8080/myApp/servlet/HelloServlet
and
http://localhost:8080/myApp/HelloServlet



The second was the correct one.
Are you seeing any errors in the logs (tomcat_home/logs directory)?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hitting HelloServlet leads to an error message about HelloWorld not being found, without HelloWorld being mentioned anywhere in your web.xml? That is most curious indeed.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf that was a typo... not a typo exactly but a copy-paste error from address bar.

http://localhost:8080/myApp/HelloServlet
and
http://localhost:8080/myApp/servlet/HelloServlet

don't work too.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:


The second was the correct one.
Are you seeing any errors in the logs (tomcat_home/logs directory)?



How do I see errors in logs??
 
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
Open them with a text editor.
Read them.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chidanand Chauhan:


you have to explicitly mention classpath



No, not at the time of execution.

While compiling, we need servlet.jar into classpath.
 
reply
    Bookmark Topic Watch Topic
  • New Topic