aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Tomcat deployment  environment 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 » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Tomcat deployment  environment" Watch "Tomcat deployment  environment" New topic
Author

Tomcat deployment environment

Jerry Bustamente
Ranch Hand

Joined: May 24, 2004
Posts: 90
Greetings,

I have had a numbers of problems that I believe are related to my use of Tomcat and my deployment directory structure and environment variables. Perhaps someone could confirm/correct my understanding. For this discussion I would like to leave the development environment out of scope. This example is from HF page 176.

Here is the deployment structure I am working with:

C:
jakarta-tomcat-5.5.4
webapps
listenerTest
WEB-INF contains web.xml
classes
com
example contains Dog.class, ListenerTester.class, and
MyServletContextListener.class

CLASSPATH= .;C:\MyProjects\listenerTest;C:\jakarta-tomcat-5.5.4;
C:\jakarta-tomcat-5.5.4\common\lib\servlet-api.jar;
C:\jakarta-tomcat-5.5.4\common\lib\jsp-api.jar

JAVA_HOME = C:\Program Files\Java\jdk1.5.0_01

TOMCAT_HOME = C:\jakarta-tomcat-5.5.4


My understanding is that under this configuration Tomcat will start at the install directory, look for the web-xml file in WEB-INF. Tomcat will also look for the class files in the example directory as listed above.

All three classes have a package name of com.example

Given the directory structure and the location of components (web-xml and three class files) I am at a loss to determine why Tomcat is not finding the servlet it needs.

Can anyone enlighten me?

Thanks,

Sincerely,

Jerry Bustamente
Kitty Dayal
Ranch Hand

Joined: Jul 22, 2004
Posts: 89
I believe you have to configure your deployment descriptor(web.xml) file for your servlets. If u have already configured it, then I would suggest you to post the error that you get so that we get an idea as to what goin on.
-Kitz
Stephen Galbraith
Ranch Hand

Joined: Oct 27, 2003
Posts: 90
I'm not sure, but I had problems with JAVA_HOME and tomcat if my location in JAVA_HOME had any spaces in it, but this bombs out tomcat on startup and not when trying to compile/load etc


SCJP 1.4, SCJD, SCWCD 1.4
Jerry Bustamente
Ranch Hand

Joined: May 24, 2004
Posts: 90
Kitty and Stephen,

Thank you very much for your replies. Here is my web.xml syntax:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>
<servlet-name>ListenerTester</servlet-name>
<servlet-class>com.example.ListenerTester</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ListenerTester</servlet-name>
<url-pattern>ListenTest.do</url-pattern>
</servlet-mapping>

<context-param>
<param-name>breed</param-name>
<param-value>Great Dane</param-value>
</context-param>

<listener>
<listener-class>
com.example.MyServletContextListener
</listener-class>
<listener>

</web-app>

This web.xml syntax is form p 174 of HF.

I have done a Google search with the parameter Tomcat Directory Structure and found lots of hits but they only confirmed what I already knew which of course left me more confused.

Again, your help is greatly appreciated.

Sincerely,

Jerry Bustamente
Jerry Bustamente
Ranch Hand

Joined: May 24, 2004
Posts: 90
Kitty,

I forgot to add the error message:

After starting and stopping Tomcat and typing into my browser:

http://localhost:8080/listenerTest/ListenTest.do and pressing Enter I get

HTTP Status 404 - /listenerTest/ListenTest.do

Thanks,

Jerry Bustamente
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
What happens when you pre-pend "/" to your url-pattern in the web.xml?
Jerry Bustamente
Ranch Hand

Joined: May 24, 2004
Posts: 90
Nitish,

Thank you for your reply. By prepend do you mean the syntax should appear as:

</url-pattern>ListenTest.do</url-pattern>

I would think such a syntax would be in error with the / at the beginning of the line after the < since as you know the </ usually indicates the end of the parameter.

I apologize for not testing this, your previous recommendation. I will try it when I get home this evening.

Thank you,

Jerry Bustamente
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
<url-pattern>/ListenTest.do</url-pattern>
Jerry Bustamente
Ranch Hand

Joined: May 24, 2004
Posts: 90
Thank you Carol.

I just pulled up the forum, looked at your answer and literally said, "Ah-ha, you're kidding?" But I knew you were not kidding. I'll try it tonight.

Thank you very much!

Jerry Bustamente
Jerry Bustamente
Ranch Hand

Joined: May 24, 2004
Posts: 90
Tried the url-mapping syntax without success.

Thanks for the suggestion.

Sincerely,

Jerry Bustamente
Nitish Bahadur
Ranch Hand

Joined: Aug 25, 2003
Posts: 118
Mail me the following:
1. All Java Files
2. Zip all files under webapps/listenTest. This should include the web.xml, classes directory, lib,...etcetera.

Email ===> nitishb@hotmail.com
Jerry Bustamente
Ranch Hand

Joined: May 24, 2004
Posts: 90
Thanks to Nitish my problem has been solved. I will overcome my embarassment at the fix in case someone else has the same problem.

Per Nitish, "The <param_value> should be changed to <param-value>. (the underscore versus the hypen)"

That was it.

If someone wants me to post the source code for the 3 classes and the web.xml and directory structure and environment variables let me know - I would be happy to help. This forum has helped me alot and I'd like to return the favor.

Sincerely,

Jerry Bustamente
 
 
subject: Tomcat deployment environment
 
Similar Threads
404 /listenerTest/Listen.do
Package problem in walkthrough
Servlet in Package Issue
can i have tomcat 4 and tomcat 5 together ?
struts with tomcat -not recognizing servlet.api.jar