aspose file tools*
The moose likes Tomcat and the fly likes Configuring Tomcat... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Configuring Tomcat..." Watch "Configuring Tomcat..." New topic
Author

Configuring Tomcat...

Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1511
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 ]

Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Chidanand Chauhan
Ranch Hand

Joined: Nov 10, 2005
Posts: 77
Have you configure the "Servlet-api.jar" in class path. If not then do so.

Thanks
Chidanand Chauhan
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1511
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 ]
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
I think, it is because, you forgot to add servlet-mapping tag:

Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Moved to the Apache Tomcat forum


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Jun 22, 2005
Posts: 1511
I am beginner here...
Isn't the mapping tag optional??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1511
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
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
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

Joined: Nov 10, 2005
Posts: 77
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

Joined: Jun 22, 2005
Posts: 1511
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

Joined: Dec 11, 2004
Posts: 13410



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

Joined: Mar 22, 2005
Posts: 39535
    
  27
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

Joined: Jun 22, 2005
Posts: 1511
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

Joined: Jun 22, 2005
Posts: 1511
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

Joined: Dec 11, 2004
Posts: 13410

Open them with a text editor.
Read them.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Configuring Tomcat...
 
Similar Threads
Using TLD in JSP
TOMCAT 5.5.4 + Datasource in ROOT not working
Tomcat Set
jstl problem in Spring MVC
web.xml change not working