aspose file tools*
The moose likes Servlets and the fly likes Unable to run a servlet from browser - 404 error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unable to run a servlet from browser - 404 error" Watch "Unable to run a servlet from browser - 404 error" New topic

Unable to run a servlet from browser - 404 error

SJ Rao

Joined: Mar 05, 2003
Posts: 25
I have written a simple servlet program called & the contents are
import javax.servlet.*;
import javax.servlet.http.*;
public class Test1 extends HttpServlet
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
PrintWriter out = res.getWriter();
out.println("Hello world");
I am using weblogic 8.1 & have compiled & saved the class file in "C:\bea\user_projects\applications\mydomain\DefaultWebApp\WEB-INF\classes\TestProject\Test1.class".
My web.xml is as follows :-
The path of web.xml is "C:\bea\user_projects\applications\mydomain\DefaultWebApp\WEB-INF\web.xml"
When i run the servlet in the browser giving the path "http://localhost:7001/Test1" or any other combination, it is giving me 404 error.
Can someone pl. tell me where am going wrong ? Its very urgent.
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
have you tried:
<a href="http://localhost:7001/<b rel="nofollow">TestProject</b>/Test1" target="_blank">http://localhost:7001/TestProject/Test1

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
SJ Rao

Joined: Mar 05, 2003
Posts: 25
Yes i did, but it is not working.
I have set the environment variable to "set classpath=%CLASSPATH%.;C:\bea\weblogic81\server\lib\weblogic.jar;"
After that, when i ran the servlet from the browser I am getting the error 500 - Internal server error.
Following is the error :-
javax.servlet.ServletException: [HTTP:101250][ServletContext(id=24724628,name=DefaultWebApp,context-path=)]: Servlet class TestProject.Test1 for servlet Test1 could not be loaded because a class on which it depends was not found in the classpath
java.lang.NoClassDefFoundError: TestProject/Test1 (wrong name: Test1).
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(
at weblogic.servlet.internal.ServletStubImpl.getServlet(
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(
at weblogic.servlet.internal.WebAppServletContext$
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(
at weblogic.servlet.internal.ServletRequestImpl.execute(
at weblogic.kernel.ExecuteThread.execute(

Now atleast it is recognising the path, but donno if there is something very basic am missing
SJ Rao

Joined: Mar 05, 2003
Posts: 25
oh - i got it
I was doing a very silly mistake of not putting my code in package, due to which the server didnt know where to pick up the class file from...
Don't get me started about those stupid light bulbs.
subject: Unable to run a servlet from browser - 404 error
Similar Threads
Problem with webapplication during deploying
Error 404- not found
"http://localhost:7001" on browser gives Error:404 ????
Deploying first JSP in Weblogic
How to run Servlets with Weblogic 6.1