• 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 - The requested resource is not available

 
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to complete a simple Hello World servlet example.

I have installed Tomcat 5.5 and the relevant java kits so that I can now view the Tomcat main page from http://localhost:8080/.

I have followed my book (Jess in Action) example and created the directory structure:

Tomcat 5.5\webapps\Hello\WEB-INF\classes

and added a web.xml file to the WEB-INF directory.

I have placed my Hello.java file in the classes folder and successfully compiled it so I assume my classpaths are all correct.

However, when I view the page http://localhost:8080/Hello/servlet/Hello all that is displayed is:

HTTP Status 404 - /Hello/servlet/Hello

type: Status report

message; /Hello/servlet/Hello

description: The requested resource (/Hello/servlet/Hello) is not available.


Can anybody see if I have missed something?

Thanks
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.
Tomcat, by default, now ships with the invoker servlet disabled (commented out in the web.xml file). You now need to create a 'servlet' and a 'servlet-mapping' entry in your web.xml.

Once you do, you can get rid of the "servlet/" part of your url.

Check out the following URL for more information regarding the invoker servlet:
http://faq.javaranch.com/view?InvokerServlet
 
Gary Conway
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ben, it's now working

Much appreciated
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having the same problem. I successfully compiled my Ch1Servlet.java file so it is now a .class file in my tomcat/webapps/ch1/WEB_INF/classes directory. I also included this in my web.xml file which is located in my /WEB-INF directory:

<?xml version="1.0" encoding="ISO-8851-1" ?>

<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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>

</web-app>

When I try to access the servlet at http://localhost:8080/ch1/Serv1, I am still receiving the "error 404", "The requested resource () is not available.", "type status report". Can anyone assist?
 
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
Go back and read that Invoker servlet article again.



ALL classes used in servlets should be in a package and the class file located according to the package.

The reason being that the JVM will look for your (no package) class in the "current" directory - you have no control over what Tomcat considers the current directory.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jon Bexiga wrote:I am having the same problem. I successfully compiled my Ch1Servlet.java file so it is now a .class file in my tomcat/webapps/ch1/WEB_INF/classes directory. I also included this in my web.xml file which is located in my /WEB-INF directory:

<?xml version="1.0" encoding="ISO-8851-1" ?>

<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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>

</web-app>

When I try to access the servlet at http://localhost:8080/ch1/Serv1, I am still receiving the "error 404", "The requested resource () is not available.", "type status report". Can anyone assist?



Oh... I have the same problem... and I'm too newbie to understand the article... help me pleaseeee!
 
Christian Cabizza
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jon Bexiga wrote:I am having the same problem. I successfully compiled my Ch1Servlet.java file so it is now a .class file in my tomcat/webapps/ch1/WEB_INF/classes directory. I also included this in my web.xml file which is located in my /WEB-INF directory:

<?xml version="1.0" encoding="ISO-8851-1" ?>

<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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>

</web-app>

When I try to access the servlet at http://localhost:8080/ch1/Serv1, I am still receiving the "error 404", "The requested resource () is not available.", "type status report". Can anyone assist?



Well... I'm so sorry...
My problem was in charachter set: try to substitute:

<?xml version="1.0" encoding="ISO-8851-1" ?>

with

<?xml version="1.0" encoding="UTF-8" ?>
 
Ranch Hand
Posts: 35
Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How does the encoding afftect the web.xml?
That is one part of web.xml that I have never paid attention to . Could someone please clarify.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for posting this... the change to UTF-8 saved what is left of my already fleeting sanity.
I have been researching this problem to no avail for weeks.

Robyn
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,

Needless to say I've the same problem with my Tomcat application that you all were mentioning. I'm running my tomcat in a virtual CentOS machine on my laptop, and I've even modified the encoding to UTF-8, but the problem persists...My app is called snoopy and the web.xml looks like this:


The app is present in the /webapps directory, but I'm getting nowhere through the inumerable restarts and reconfigurations:

[root@localhost webapps]# ls
balancer jsp-examples ROOT servlets-examples snoopy snoopy.war tomcat-docs webdav

A problem with the recompiling of the .war file perhaps? Dunno, suggestions are welcome (I've already looked at the page mentioned by Ben, to no avail.)
 
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Mindless Abomination", please check your private messages regarding an important administrative matter.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read: UseCodeTags

And put your servlet in a package other than the default. This is a recording.
 
Danny Glover
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please read: UseCodeTags

And put your servlet in a package other than the default. This is a recording.



sorry Bear, I didn't quite understand what you meant. Could you be a little more specific?

Thanks a lot,

Dan

PS Promise I'll use quotes next time
 
Devaka Cooray
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Mindless Abomination", please understand that it is mandatory to follow the instructions of the private message which I sent to you.
 
Devaka Cooray
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mindless Abomination wrote:sorry Bear, I didn't quite understand what you meant. Could you be a little more specific?


It's about your servlet class. You should package it using a proper package definition.
Then use the fully-qualified class name for the <servlet-class> element.
 
Danny Glover
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Devaka Cooray wrote:

Mindless Abomination wrote:sorry Bear, I didn't quite understand what you meant. Could you be a little more specific?


It's about your servlet class. You should package it using a proper package definition.
Then use the fully-qualified class name for the <servlet-class> element.


Roger that , thanks for the tip. I'll change my name if you insist
 
Devaka Cooray
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mindless Abomination wrote:I'll change my name if you insist


Please check your private messages for a warning.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


whenever this message comes,it clearly means there is smthng wrong in your web.xml file........check if every start tag has an end tag and vice versa....

also make sure you dont miss the / in servlet mapping tag
 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to javaRanch .
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Gary

Maybe if you take your all codes here, others can help you solve it more possibility.

What's your opinion?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Along with it seems everyone else who has tried the Head First Servlet book, I cannot make this work.

I have read through this thread, and various other on the internet. Changed my web.xml (repeatedly), put my source in a package, all to no avail.

Could some kind person who has fought their way through this provide a full working example of the web.xml & tomcat directories?

Thanks

Simon
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For what it is worth, I just started the Heads First Servlet and JSP book as well. I am running Fedora with tomcat6. I got the example to work by creating a directory called WEB-INF and a classes subdirectory in WEB-INF. I copied the web.xml file into WEB-INF and the Ch1Servlet.class to WEB-INF/classes/. My web.xml was:


 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You need to give fully qualified name for the Servlet Class.
 
Ranch Hand
Posts: 47
MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,
I am working with JSP and Java Beans in my project , my .war file is inside C:\Program Files\apache-tomcat-6.0.32\webapps folder, when I try to run it from tomcat manager it gives error
HTTP Status 404-The requested resource (/StoreManagement/) is not available.
Can anybody tell me what I missed?
Thank you in advance!
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had declared the class as default access type. Declaring it as public solved my problem. Even I was getting the 404 error. I tried everything mentioned above but careful reading of the tomcat logs showed following errors


eventually, I realized my mistake.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same problem, if anyone else is looking for a solution and comes across this putting the dependency in pom.xml fixed it


<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>


<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am converting my whole application on Tomcat. So When i am doing copy paste the web.xml as it is , it is giving error The requested resource (/resume/) is not available..But if i m Doing One by One calling Servlet Its working Fine So i want to Ask One things that At the time of running tomcat First Search All the Entry Of web.xml is it exist or not?? Means It serch all the entry inside of this??
<servlet>
<servlet-name>closingAuction</servlet-name>
<servlet-class>com.ireps.auction.utilities.CloseForwardAuction</servlet-class>
</servlet>

But if am doing entry one by one in web.xml and copy paste the struts-config.xml All The Entry , Then It is not showing the error.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Devin Crane,
Your post was moved to a new topic.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I had the same problem with my project in eclipse.
It was working fine in NetBeans but not in eclipse.

For Running it in Eclipse you have to move your JSP files to WebContent folder, then Clean the project and you are good to go...
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello, I'm having the same issue. I'm also getting something like this --The requested resource [/Mytest/insert] is not available
below is my xml file. could somebody please help me with it its been since 2 days since and I'm  still trynna figure this out.

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
        version="3.1">
   
<servlet>
<servlet-name>InsertServlet</servlet-name>
<servlet-class>com.worklog.servlet.InsertServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>InsertServlet</servlet-name>
<url-pattern>/insert</url-pattern>
</servlet-mapping>

</web-app>
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Yasiru!

I don't see anything wrong with your web.xml. These days we'd probably put an annotation on the Servlet class source instead, but the old ways work just fine and can be expected to do so for the foreseeable future.

So what's probably wrong is your deployment. Tomcat is looking for a webapp that was deployed under the case-sensitive Context name of "/Mytest". That typically means that there should be a WAR file or an unzipped ("exploded") WAR directory in the TOMCAT_HOME/webapps directory. That is, TOMCAT_HOME/webapps/Mytest.war or a directory named TOMCAT_HOME/webapps/MyTest.

And inside that WAR, the web.xml file should be in a subdirectory named WEB-INF. All names are case sensitive and do be careful not to use a word processing program to name things, since what they think a "-" character should be in not necessarily the simple ASCII dash that's all that Tomcat (or any JEE server) actually wants.
 
reply
    Bookmark Topic Watch Topic
  • New Topic