• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat - The requested resource is not available

 
Gary Conway
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Ben, it's now working

Much appreciated
 
Jay Brimestone
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • 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.
 
Christian Cabizza
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • 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" ?>
 
Royston Monteiro
Ranch Hand
Posts: 35
Java Linux Spring
  • Mark post as helpful
  • send pies
  • 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.
 
Robyn Morin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
 
Danny Glover
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.)
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4330
238
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Mindless Abomination", please check your private messages regarding an important administrative matter.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
ExamLab Creator
Marshal
Pie
Posts: 4330
238
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
ExamLab Creator
Marshal
Pie
Posts: 4330
238
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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
ExamLab Creator
Marshal
Pie
Posts: 4330
238
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mindless Abomination wrote:I'll change my name if you insist

Please check your private messages for a warning.
 
Benson Sebastian
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to javaRanch .
 
Han Jie
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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?
 
Simon Wilsona
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
J Adcock
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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:


 
Srinivasa Kumar Meda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You need to give fully qualified name for the Servlet Class.
 
Divya Chandel
Ranch Hand
Posts: 47
MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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!
 
Milan Sutaria
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • 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.
 
Lina Zhukov
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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>
 
naval kumar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Devin Crane,
Your post was moved to a new topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic