Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Status 404 - Servlet 'x' is not available.

 
Jose Alvarez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm doing a web page using Glassfish tools bundle for Eclipse (I use the server provided by the Glassfish).

I have a package called "Interfaz" where I put the servlets. I added a servlet called "RegistroConciertos" but when I try to execute this, I receive the exception mentioned in the title of my topic. I try to add more servlets, but I receive the same exception. With the servlets what I have created above, I don't have problems.

At the first time I try to run the servlet after the server starts, I receive the exception HTTP Status 500 - javax.servlet.ServletException: PWC1397: Wrapper cannot find servlet class 'x' or a class it depends on.
And then, if I touch "Refresh" in the WebBrowser provides by GlassFish, I receive the exception HTTP 404.

What can I do?

Thanks for all.
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you add the proper url-mapping elements to your web.xml file?
 
Jose Alvarez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Did you add the proper url-mapping elements to your web.xml file?


Yes, because Glassfish add the elements automatically. But I saw the web.xml file and the tags are correctly.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't tell us, show us.

Otherwise, all we can do is to guess.
 
Jose Alvarez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Don't tell us, show us.

Otherwise, all we can do is to guess.


What do you need to see? Tell me and I show what you want.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jose Juan wrote:But I saw the web.xml file and the tags are correctly.


Then show us THAT.
 
Jose Alvarez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I used the old version of the web page and it works. Thanks for all.
 
shivam purohit
Greenhorn
Posts: 12
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am getting an error while running hello world program in eclipse using tomcat as plug in .

"The requested resource (/ServletExam/) is not available".

My web.xml is following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> -->

<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>

I think i have either missed something in this or something wrong.
I have read some post regarding this but could not get any help.
please assit me.
Thanks.

please help me asap.as its urgent.
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no URL mapping for "/ServletExam/", only for "/HelloWorld". And you shouldn't use classes in the default package.

shivam purohit wrote:please help me asap.as its urgent.

Please EaseUp. There is no such thing as urgent or "ASAP" around here.
 
shivam purohit
Greenhorn
Posts: 12
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:There is no URL mapping for "/ServletExam/", only for "/HelloWorld". And you shouldn't use classes in the default package.

shivam purohit wrote:please help me asap.as its urgent.

Please EaseUp. There is no such thing as urgent or "ASAP" around here.



Hi,
as i am a new bee here and new to servlet too.
can you please explain through code. so i can undrstand.
thnks
 
shivam purohit
Greenhorn
Posts: 12
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
as i am a new bee here and new to servlet too.
can you please explain through code. so i can undrstand.

I have changed my project name from ServletExam to HelloWorld.
thnks
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell us which URL you're trying to open?

You only have one URL mapping, for /HelloWorld. You have no welcome file list. That means that you can only access two types of URLs (if your project is still named ServletExam):
- http://localhost:8080/ServletExam/HelloWorld which will open the servlet.
- http://localhost:8080/ServletExam/xxx where xxx is a direct path to a JSP file, HTML file, image etc. In other words, anything that isn't a servlet (or inside the WEB-INF folder).
 
shivam purohit
Greenhorn
Posts: 12
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.At first ,i am using tomcat as plug in in eclipse (so not using http://localhost:8080)
2. Yes i ddnt use any jsp any html page, cos i hv heard/read somewhere that we can use servlet without jsp also.
then cn i use for the same.
or guide me if its not possible.(
in this case i will add a new jsp/html )page then will try to run.


details:
projet name:Hello1
java file in src folder : HelloWorld

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet{
/**
*
*/
private static final long serialVersionUID = 1L;

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head><title>Hello World</title></title>");
pw.println("<body>");
pw.println("<h1>Hello World</h1>");
pw.println("</body></html>");
}
}


web.xml in web-inf

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> -->
<web-app xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld*</url-pattern>
</servlet-mapping>
</web-app>


jar file in web-inf\lib---servlet-api.jar



thts what i am using.
 
shivam purohit
Greenhorn
Posts: 12
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In elipse's browser url is :::: http://localhost:8180/Hello1/
as i have changed port cos 8080 is used by oracle.

Thnks:-)
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivam purohit wrote:ddnt ... cos ... hv ... cn ... thts ...Thnks

Please UseRealWords.

With that web.xml file only URLs that start with http://localhost:8180/Hello1/HelloWorld are supported.
 
shivam purohit
Greenhorn
Posts: 12
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,
Thanks
But Its still not working and giving following error:

The requested resource (/Hello1/HelloWorld) is not available.


 
Prasad Krishnegowda
Ranch Hand
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting the servlet in a package.
 
shivam purohit
Greenhorn
Posts: 12
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi prasad,
are you getting something wrong in my code.

OK if i will put that servlet into package, in web.xml,what changes should i have to do??
 
Prasad Krishnegowda
Ranch Hand
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In web.xml, you need to change the value of <servlet-class> to hold the fully qualified name of the servlet.
 
bindu sadanandan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kindly ensure that in each servlet code before each of the imports...the following code is entered

package Interfaz;

else it wont be able to find that servlet under the package even though you might see the servlet in the tree structure under Interfaz.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic