Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error 404: File not found: loadservlet

 
rajan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
}
}
---------------------------------------------------------------
 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Rajan, you still need to change your login name, it still does not meet Javaranch standards.

Thank you

Mark
 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic