• 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

Tomcat deployment environment

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens when you pre-pend "/" to your url-pattern in the web.xml?
 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<url-pattern>/ListenTest.do</url-pattern>
 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried the url-mapping syntax without success.

Thanks for the suggestion.

Sincerely,

Jerry Bustamente
 
Nitish Bahadur
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic