• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to run a servlet from browser - 404 error  RSS feed

 
SJ Rao
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a simple servlet program called Test1.java & the contents are
import java.io.*;
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 :-
<web-app>
<servlet>
<servlet-name>Test1</servlet-name>
<servlet-class>TestProject.Test1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test1</servlet-name>
<url-pattern>/Test1</url-pattern>
</servlet-mapping>
</web-app>
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.
Thanks
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you tried:
<a href="http://localhost:7001/<b rel="nofollow">TestProject</b>/Test1" target="_blank">http://localhost:7001/TestProject/Test1
 
SJ Rao
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
C:\bea\user_projects\applications\mydomain\DefaultWebApp;C:\bea\user_projects\applications\mydomain\DefaultWebApp\WEB-INF\classes.
java.lang.NoClassDefFoundError: TestProject/Test1 (wrong name: Test1).
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:800)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:504)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:349)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

Now atleast it is recognising the path, but donno if there is something very basic am missing
 
SJ Rao
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!