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 Servlet not running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet not running" Watch "Servlet not running" New topic
Author

Servlet not running

Ravinder S Edhan
Ranch Hand

Joined: Dec 15, 2003
Posts: 57
Hi Guys
Though this is a very simple problem but still I can't find any reason why my servlet is not running.
My java file is as follows:
--------------------------
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class threadServlet extends HttpServlet {
int i = 0;
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
synchronized(this){
try{
Thread.currentThread().sleep(5000);
} catch (InterruptedException e) {
System.err.println(e);
}
}
out.println("Finished: " + i++);
out.close();
}
}
-----------------
<web-inf>
<!-- helloServlet.java -->
<servlet>
<servlet-name>helloServlet</servlet-name>
<servlet-class>helloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>helloServlet</servlet-name>
<url-pattern>/helloServlet</url-pattern>
</servlet-mapping>
<!-- threadServlet.java -->
<servlet>
<servlet-name>threadServlet</servlet-name>
<servlet-class>threadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>threadServlet</servlet-name>
<url-pattern>/threadServlet</url-pattern>
</servlet-mapping>
</web-inf>
--------------
Error shown :-> The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5

There is your problem. Put helloServlet in a package and put the compiled class in the correct package directory under WEB-INF/classes.
The reason being that if the class loader sees a request for a class without a package it looks in the "current" directory - you have no control over the current directory in a servlet environment.
Ravinder S Edhan
Ranch Hand

Joined: Dec 15, 2003
Posts: 57
Hi
I've placed the complied file in WEB-INF\classes folder.
The helloServlet part in xml file was running fine, I mean to say that my helloServlet was running fine. Then instead of creating a new xml file for my threadServlet file, I decided to put in same xml file. but this is not running.. I even tried running this by removing the helloServlet code in xml file...but still in vain.. It is showing me same error
Ravinder S Edhan
Ranch Hand

Joined: Dec 15, 2003
Posts: 57
Hi
Thanx for providing the solution...
I restarted the server and now the servlet is running...But can't understand why this happened so...should I have to restatrt the server again and again.
Bye
Engin Okucu
Ranch Hand

Joined: Feb 09, 2002
Posts: 174
hi Ravinder,
Here is a help for you to not restart the next time you compile.http://www.coreservlets.com/Apache-Tomcat-Tutorial/
See 2. Configure Tomcat
4.Turn on servlet reloading
Good luck.
Ravinder S Edhan
Ranch Hand

Joined: Dec 15, 2003
Posts: 57
hi Engin,

Thanx man ..... But I'm using weblogic server and the problem of restarting the server is also solved.
Bye
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet not running