• 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

Not able to execute servlet

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am running tomcat 6 and the test page is seen fine (so I guess tomcat is running fine).

I have a test servlet process.java. I have placed it in this format:
/usr/share/tomcat6/webapps/sample/WEB-INF/classes/process.java

I have also placed the web.xml in /usr/share/tomcat6/webapps/sample/WEB-INF/web.xml . It looks like this:


I stopped and started tomcat after this.

When I run http://localhost:8080/sample/process it says it The requested resource /sample/process is not available.

Can some on help me identify what I am doing wrong?

Bharath
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There could be any reason for the error. The web.xml looks well formed to me. Can you show us the servlet code. Also check the tomcat logs (in /usr/share/tomcat6/logs directory) to see if there's any error stack trace. You can also check the tomcat console to see if there's any error when you use that URL in the browser...
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the class file must not be in the root directory which it is in this case. Not sure though.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


ALL classes used in servlets MUST be in a package. The reason being that the JVM will look for a class in the default (no)package in the "current" directory. You have NO control over the current directory in the servlet environment.

Years ago the first developers thought they would do new programmers a favor with the "invoker" servlet which would let you whip out a test servlet without a package and run it indirectly. Here is the ranch FAQ on the dreaded invoker.

So - always a package.

Bill
 
Neo Wills
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Putting it in a package did help. Thanks Bill. Also I moved this out to a separate directory and updated the conf file (without putting it in a package). That works as well.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic