File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Error 404: File not found: loadservlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Error 404: File not found: loadservlet " Watch "Error 404: File not found: loadservlet " New topic
Author

Error 404: File not found: loadservlet

rajan
Greenhorn

Joined: Aug 25, 2004
Posts: 1
am trying to run servlet in WSAD and am getting Error 404: File not found: loadservlet .The actual application is am calling ejb from servlet and trying to run it thru WSAD TEST SERVER.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

"Rami"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Rami,

Once you've changed your display name we're going to need a bit more information than that. A good start would be the relevant section of your web.xml file where you define your servlet and its mapping, the location of your servlet class file, plus the URL that you're using to access it. The server appears to be trying to tell you that, for whatever reason, it can't find your servlet.

Jules
Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
I have a similar problem. The error message is as below..

------------------------------------------------------------------------------
description The requested resource (/servlets-examples/servlet/HelloWorldExample) is not available.
-----------------------------------------------------------------------------

I used the demo class file ("http://localhost:8080/servlets-examples/servlet/HelloWorldExample") and it worked.

When I amended and recompiled, it worked too.

However, when I create a new source file, it doesn't work. I tried it in school and it work. But on my home pc, it doesn't. I put the file in ("C:\Tomcat5\webapps\servlets-examples\WEB-INF\classes"), which is the same folder the demos are in.

I wonder what's amissed.

Mine source is below

-----------------------------------------------------------------------
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
// Support classes
import java.io.PrintWriter;
import java.io.IOException;

public class HelloServlet extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException {

// Specify the content type is HTML
response.setContentType("text/html");
PrintWriter out = response.getWriter();

// Generate the HTML response
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Hello Servlet</TITLE>");
out.println("</HEAD>");
out.println("<BODY BGCOLOR='white'>");
out.println("<B>Hello, World</B>");
out.println("</BODY>");
out.println("</HTML>");

out.close();
}
}
---------------------------------------------------------------


Do you have a parka?<br /> <br /><a href="http://sg.geocities.com/inschooool" target="_blank" rel="nofollow">Visit my homepage</a> | <a href="http://parka.deviantart.com/" target="_blank" rel="nofollow">Parka Deviantart gallery</a>
Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
I get the following error when I use Textpad to compile. But no errors when I use MSDOS (obviously was hidden).

What's amissed?

-------------------------------------------------------------------------

F:\java\HelloServlet.java:2: cannot resolve symbol
symbol : class HttpServlet
location: package http
import javax.servlet.http.HttpServlet;
^
F:\java\HelloServlet.java:3: cannot resolve symbol
symbol : class HttpServletRequest
location: package http
import javax.servlet.http.HttpServletRequest;
^
F:\java\HelloServlet.java:4: cannot resolve symbol
symbol : class HttpServletResponse
location: package http
import javax.servlet.http.HttpServletResponse;
^
F:\java\HelloServlet.java:9: cannot resolve symbol
symbol : class HttpServlet
location: class HelloServlet
public class HelloServlet extends HttpServlet {
^
F:\java\HelloServlet.java:11: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloServlet
public void doGet(HttpServletRequest request,
^
F:\java\HelloServlet.java:12: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloServlet
HttpServletResponse response)
^
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Parka (you'll also need to change your display name as was indicated to "Rami" earlier in this thread),

Your compile error appears to be due to the TextPad using a different classpath to that found in the %CLASSPATH% environment variable in "MSDOS". The classpath is missing your servlet JAR file - the name varies depending on the servlet container you're using.

As for your strange servlet behaviour, I'm not sure exactly what you're doing. Can you please explain it again? What URL are you using when you get the error message?

Jules
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Two things to watch out for:
1. If you don't put your servlet class in a package you can get hard to interpret errors
2. If your URL uses "/servlet/" as in:
http://localhost:8080/servlets-examples/servlet/HelloWorldExample
That probably requires the "invoker" servlet - the cause of much confusion and annoyance to new programmers. See the invoker servlet FAQ.
Bill
Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
Hello there Jules,

I meant that I recoded the HelloWorldExample to have a background color of black, and recompiled it.

Then I put it back into the same folder as before, "C:\Tomcat5\webapps\servlets-examples\WEB-INF\classes", in this case.

Typed "http://localhost:8080/servlets-examples/servlet/HelloWorldExample" in the address bar...

And it works. The page turned black.

However, when I put another class file I did back in school into this folder, it couldn't work. It showed me the 404 error.

Parka
Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
Originally posted by William Brogden:
Two things to watch out for:
1. If you don't put your servlet class in a package you can get hard to interpret errors
2. If your URL uses "/servlet/" as in:
http://localhost:8080/servlets-examples/servlet/HelloWorldExample
That probably requires the "invoker" servlet - the cause of much confusion and annoyance to new programmers. See the invoker servlet FAQ.
Bill


Thanks for the help.

I followed the FAQ but it couldn't work for me.

I tried changing the "conf/web.xml" file but I can't start my Tomcat server as a result.

I've also edited "WEB-INF/web.xml" file. But I was shown the following error. (code 505)

---------------------------------------------------------------------------
ption The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.util.MissingResourceException: Can't find bundle for base name LocalStrings, locale en
java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
java.util.ResourceBundle.getBundleImpl(Unknown Source)
java.util.ResourceBundle.getBundle(Unknown Source)
HelloWorldExample.doGet(HelloWorldExample.java:39)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

----------------------------------------------------------------------------
[ August 29, 2004: Message edited by: Parka ]
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Parka,

It's not much use giving the full details for the case that *does* work. You need to give the full details for the case that *doesn't* work so we can see what you're doing wrong.

Which directory are you putting the class file you did in school in? Does it have a package? What URL are you using to access it? If you're using the InvokerServlet then if you get the URL and the path right I can't see why it wouldn't work (with a 404).

Jules
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

"Parka"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

And Rajan, you still need to change your login name, it still does not meet Javaranch standards.

Thank you

Mark
Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
Finally solved my problem

Apparently I didn't set the classpath correctly.

And secondly, the mystery of the same-file-not-working-in-different-folder problem was actually caused by not having a web.xml file in WEB-INF folder.

Man.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error 404: File not found: loadservlet