Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat container not working

 
Arun Giridharan
Ranch Hand
Posts: 290
Debian Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As ,it's specified in the Book (Head First Servlet and JSP) that ,whenever a tomcat or any other container starts it will go to the webapp and come to know the <servlet-class>.

In my example i have ,i have not given the correct web.xml[means syntax is wrong] ,i taught i may get some error on deployment but i'm not getting than later i tried to restart my tomcat , than i may get so [like DeploymentException or something] ,i didn't get.

See my syntax is wrong, <servlet-class>
Page Number in the book is 102,Chapter 4 .

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually a URL ending in ".do" is a Struts URL. Struts requires mapping those URLs to the Struts Action Servlet, not a user-written servlet. In any event the "servlet-class" element in web.xml should envelope a fully-qualified servlet classname.
 
Arun Giridharan
Ranch Hand
Posts: 290
Debian Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why it's(Tomcat Container) not giving DeploymentException.??!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


is NOT valid XML - look at the servlet-class element. Tomcat will not recognize a web app if the web.xml is incorrect, causing a parse error early in the loading processs.

Fix your web.xml and restart - NOTE: servlet-class MUST be in a package and the class file in a directory corresponding to the package.

Bill
Note that there will be an error report somewhere in the Tomcat logs.
 
Arun Giridharan
Ranch Hand
Posts: 290
Debian Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:

is NOT valid XML - look at the servlet-class element. Tomcat will not recognize a web app if the web.xml is incorrect, causing a parse error early in the loading processs.



I know it's not valid XML. i'm not getting parse error early in the loading processs.

( I don't know why ,i'm not getting parse error early in the deployment process.)
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IF Tomcat does not try to parse web.xml
THEN Tomcat does not think there is a web application in the directory so it does not even bother to try to parse web.xml
THEREFORE There is something wrong with your directory layout or configuration files.

Bill
 
Arun Giridharan
Ranch Hand
Posts: 290
Debian Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:IF Tomcat does not try to parse web.xml
THEN Tomcat does not think there is a web application in the directory so it does not even bother to try to parse web.xml
THEREFORE There is something wrong with your directory layout or configuration files.

Bill


How to find out what's going wrong ?? (can i post my simple servlet program.)
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to find out what's going wrong ?? (can i post my simple servlet program.)


As I tried to point out, your program has NOTHING to do with your problem - Tomcat is not even trying to load your program so any program errors remain undiscoverable.

It is your configuration - ie the directory organization/layout and configuration files - which Tomcat is not recognizing as a web application.

Presumably your tomcat installation has some working applications such as "examples." Study how working examples are laid out.

One common beginner error has to do with directory names - Java cares about case in directory and file names even if windows doesn't.

So web-inf will not be recognized - WEB-INF is required, etc etc.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic