Tomcat: reloading modified servlets?

hi
in tomcat it's possible to configure a servlet context to automaticaly reload if the servlet was rebuild. i know how to do that and i works.
what i want to change is the reation time of tomcat. it sometimes takes quite a long time till tomcat realizes that a servlet has changed and reloads it. I think that mechnism is quite simple, kind of a thread that looks for a new modifed date of the servlet file and reloads or not and goes to sleep again for a amount of time. My question: is there a possibility to configurate that parameter that handels the sleep time?
thanx for your help!

If you get hold of the source (this is from v4.0.4)
Look in org.apache.cataline.loader.StandardLoader.java
you will see at line 164 that this value has a hard coded default of 15 (seconds).
There is a public void setCheckInterval(int checkInterval) but I'm not sure where you can configure this to be set - I can't find any classes which call it.
It might be possible to access the loader from a servlet run at start up with an init() method that sets a new value.
HH

Similar Messages

  • Do we need to restart the Tomcat server each time when we modify servlets?

    Hi Friends,
    Do we need to restart the Tomcat server each time when we modify servlets. Or is there any otherway to achieve the functionalitly?
    Thanks and Regards,
    JG

    JamesGeorge wrote:
    Hi kajbj,
    Java guys are mostly using TOMCAT,so for me it seems to be the best place.That's not correct. Most people who are writing stuff for the web might be using Tomcat, but there are lots and lots of Java applications that aren't for the web.
    Is there any other reason behind your question.Yes, this forum is named "New to Java" and Tomcat questions shouldn't be asked here, even if people knows the answer to you question. You will probably get better and more detailed answers in a Tomcat forum. All othe guys there are actually using Tomcat, and they know the small differences between the different versions, and how they behave on different operating systems. They do also know if you need to make configurations changes, and where you should make them.
    So in future, please ask questions in a forum that is specific to the product that you are using.

  • Modified  Servlet not visible

    Hi,
    I created a servlet & then ran it , it worked fine. After that I modified it so that it should display a different message on browser but its displaying the previous staff. Strangely even if I delete the servlet & then try to access it using a URL , I will see the same stuff which present in the servlet before starting the tomcat. However if I stop tomcat & hen restart it again I will see the modified servlet or error message if servlet not available. How can I get around with this prob of viewing the modified servlet without restarting the tomcat.
    Zulfi.

    add reloadable attribute to the Context entry in conf/server.xml. by default it does not include reloadable, change
        <!-- Tomcat Root Context -->
        <Context path="" docBase="ROOT" debug="0"/>to
        <!-- Tomcat Root Context -->
        <Context path="" docBase="ROOT" debug="0" reloadable="true"/>this will tell tomcat to reload the servlet after being modified without restarting server.

  • How do I get the Tomcat port using Servlet.

    I am running Apache + Tomcat. All request are going though Apache. How do I get the Tomcat port using Servlet.

    See:
    ServletRequest.getServerPort()This will give the port upon which the request was recieved . . .which I blelieve is what you are looking for.

  • How can i avoid restarting tomcat server when servlet is modified?

    please advice me that how can i avoid restarting the tomcat server, whenever a servlet file is modified in my application. is their any way ?

    No probs. Here's how I do things...
    1. Install tomcat as normal (e.g. I install to C:\Apps\jakarta-tomcat-5.5.4)
    2. Create a webapps directory in your eclipse project with the following directory structure
    MyEclipseProject
       - src
       - conf
       - webapps
          - MyApplication
             - META-INF
             - WEB-INF
                - classes
                - lib
                - pages3. Set the project's output folder (e.g. bin folder) to webapps/MyApplication/WEB-INF/classes
    4. Put all your jar files in the lib directory
    5. Put JSPs / HTML in the pages directory (you may also want to create additional directories for TLDs, config files etc)
    6. Ensure your web.xml is in the WEB-INF directory
    7. Although it isn't essential I create a context.xml file and store it in META-INF, e.g.
    <Context reloadable="true">
        <!-- Default set of monitored resources -->
         <WatchedResource>WEB-INF/web.xml</WatchedResource>
         <WatchedResource>WEB-INF/conf/struts/struts-config.xml</WatchedResource>
         <WatchedResource>WEB-INF/conf/struts/tiles-defs.xml</WatchedResource>
         <WatchedResource>WEB-INF/conf/struts/validation.xml</WatchedResource>     
    </Context>I use this to set monitored resources that will trigger an automatic appliation reload and to configure JAAS (not shown). See the Tomcat documentation for additional information.
    8. In the 'conf' directory I create a server.xml file used to configure Tomcat (you can copy the one from your <TOMCAT_HOME>/conf/server.xml).
    After copying the file change appBase attribute in the host element to be the full path to the webapps directory. You can also change the HTTP and HTTPS ports if you wish
    9. Download and install the Tomcat Launcher plugin from Sysdeo.
    10. In Eclipse's Preferences menu you will see a new entry for Tomcat. Click this then
    a. Set your Tomcat Version
    b. Set your Tomcat Home
    c. Set "Context declaration mode" to server.xml
    d. Set the configuration file to the full path to your server.xml file created in step 8
    On the "Advanced " sub page select all relevant projects to add to the Tomcat classpath
    On the "JVM Settings" page add all the jars in your WEB-INF lib directory to the class path
    On the "Source Path" page select all relevant projects
    Now if you start Tomcat using the Tomcat icon, you will be able to remote debug your application. If you change web.xml (or any other file in your context.xml watched resources) it will automatically reload. Any changes to JSPs will automatically be picked up (providing your tell your browser not to use the page in cache - e.g. CTRL+F5 in IE)
    There are some limitations that I'm still working on however. Primarily that I haven't included the Tomcat Manager application in my webapps directory, so Sysdeo cannot perform a reload. This means that if I change a source file, and eclipse auotmatically rebuilds, Tomcat doesn't pick up the change unless I either change a watched resource file (e.g. web.xml) or stop and restart Tomcat.
    There's no reason why this can't be fixed, I just haven't got round to it yet.
    I'm sure there are lots of other (probably better) ways of achieving the same thing. This was the first method I tried and it worked, so I stuck with it. I'm not a Tomcat config guru and I'm sure other forum users could provide some improvements should they wish.
    Post if you get into trouble, however I won't be able to respond until next week.
    Cheers,
    Steve

  • Restart tomcat at every servlet modify?

    Hi,
    I'm using tomcat 5.5 and working on some servlets, but when I execute a servlet (http://localhost/my_servlet)
    and then I modify and recompile it, I have to shutdown and restart tomcat to see the new version on work.
    Is this normal? Can I avoid this?
    Thanx

    Well, I have solved the problem editing contex.wml file modifying the line:
    <Context>into the line:
    <Context reloadable="true">Now it works even if refresh time is not so low...
    Thanx to all.
    P.S.
    Adding the line
    <DefaultContext reloadable="true"/>into server.xml file I don't have obtained any result.

  • Regarding TOmcat Restart evertime servlet is modified

    Hi,
    Myself Ashwin MIttal, using Tomcat on the Linux and Windows OS. Hey I am developing servlet and when I deploy servlet each time. I have to restart the Tomcat ....
    Is there anyway to solve the problem means There is no need to restart the Tomcat when eber serlvet is modified..
    Regards,
    Ashwin Mittal.

    In the context, type reloadable="true"yup, this is a better option.But you want to only do this on your developement machine. reloadable contexts take up a lot of resources, every x amount of time, the server has to check the classpath directories for modified time. Even if you don't make changes, this takes up resources. So once you move from development to deployment you want to turn this off...

  • LocateRegistry.getRegistry() fails when called from Tomcat 5.5 servlet

    I'm trying to access a simple RMI server from a Tomcat 5.5 (Java 5) servlet. I get access exceptions having to do with java.util.logging.LoggingPermission. (The RMI server works fine with a simple command line Java app.)
    Is there some reason that calling getRegistry() from within a servlet should fail? Is there some reason that it should require LoggingPermission?
    I've modified the catalina.policy file to grant all permission to everything but I still get the same errors.
    Surely there is a way to make RMI calls from a servlet. Any suggestions on how to fix this? Thanks.

    show us the script

  • Tomcat 4.0,Servlet 2.3 and JSP1.2

    Trying to figure out what to do with the Servlet 2.3 and JSP 1.2 zip files. Have the JDK 1.4 and Tomcat 4.0 already installed. Cant find any instructions at all on the java website on where to unzip the classes. JDK1.4/lib?Thanks in advance.

    Thanks for the reply. So then where do the javax.* classes reside? How does the servlet.java file find the imported servlet classes when the pgm is compiled? Why is java such a PITA to get up and running? Sorry. I keep getting:
    A Servlet Exception Has Occurred
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    if (pageContext != null) pageContext.handlePageException(t);
    when I try to run a .jsp with tomcat.

  • Web.xml Tomcat 5.0 Servlet problem

    Hey guys....
    The last time I used a servlet was before the new change in security in Tomcat. Ive been looking all over the net for some easy references about how they are to be mapped but no matter what I try nothing seems to work.
    My servlet is located in ROOT\Admin\WEB-INF\classes\colt and is called AddOLO.class
    My web.xml file is located in ROOT\Admin\WEB-INF and contains the following code:
    <servlet>
    <servlet-name>AddOLO</servlet-name>
    <servlet-class>colt.AddOLO</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>AddOLO</servlet-name>
    <url-pattern>/Admin/add</url-pattern>
    </servlet-mapping>
    On the HTML form invoking the Servlet (addOLO.html) Im using the following small piece of code
    <form action="http://Colt/Admin/servlet/AddOLO" method="post" align="centre">
    The server is operating on Port 80.
    All I seem to be getting is a 404 Error Saying The requested resource (/Admin/servlet/AddOLO) is not available. Can anyone see what is wrong here?
    Thanks in advance

    I don't think there's anything to prohibit you from deploying servlets in ROOT, but webapps that have pages and servlets that work together should be in their own context. That's what you did when you created the directory under webapps. I think it's the right way to deploy web apps. Even better, learn how to create and deploy WAR files:
    http://access1.sun.com/techarticles/simple.WAR.html
    Once you have a WAR, which is simply a JAR'd version of the directory you just created under webapps, you can simply pick it up and deploy it by dropping it into the webapps directory of any Tomcat server. Tomcat will unpack it for you. - MOD

  • Tomcat, LDAP, SSL, Servlet

    Hi - I have already written a servlet that binds against a LDAP Server normally. Now I need to implement SSL on it. I would like to know if anyone has any code that simply binds against an LDAP Server using SSL.
    I use the servlet on Tomcat to connect to the LDAP Server .. so...
    1. Do I need to install JSSE alongwith Tomcat to use ssl?
    2. Since the servlet acts as the Client to the LDAP Server - is it enough to simply add ssl parameters to the code (and include a cert store path)?
    I would only require to know simple steps to ssl-enable my existing application ...
    please help!

    I had problems getting SSL to work. The only modifications that you should need to make are in the connection.
    Here is the URL.
    http://forum.java.sun.com/thread.jsp?forum=51&thread=322566

  • Tomcat embedded + add servlet

    Hi,
    I need to use Tomcat in an embedded mode. No problem to do this. The only problem is that I want to have a servlet added to the server at startup coding it directly in my start method. I have saw that it is possible with Jetty, is it possible too with Tomcat ?
    Thanks.

    Hi,
    download the Tomcat "Embedded" version at http://tomcat.apache.org/download-55.cgi and try the following code:
    import org.apache.catalina.*;
    import org.apache.catalina.connector.*;
    import org.apache.catalina.realm.*;
    import org.apache.catalina.startup.*;
    import org.apache.catalina.users.*;
    public class EmbeddedTomcat
      // Instance variables:
      private String    name;
      private int       portNumber;
      private Embedded  embedded;
      private Engine    baseEngine;
      private Host      baseHost;
      private Connector httpConnector;
      /** Creates a new instance of EmbeddedTomcat */
      public EmbeddedTomcat(
        String name,
        int    portNumber)
        this.name = name;
        this.portNumber = portNumber;
        init();
      private void init()
        MemoryRealm realm;
        Context     context;
        String      baseEngineName;
        String      hostName;
        embedded = new Embedded();
        // set default logger and realm
           FileLogger fileLog = new FileLogger();
           fileLog.setDirectory(".");
           fileLog.setPrefix(name);
           fileLog.setSuffix(".log");
           fileLog.setTimestamp(true);
           embedded.setLogger(fileLog);
        realm = new MemoryRealm();
        embedded.setRealm(realm);
        // create an Engine
        baseEngine = embedded.createEngine();
        // set Engine properties
        baseEngineName = name + "Engine";
        hostName = name + "Host";
        baseEngine.setName(baseEngineName);
        baseEngine.setDefaultHost(hostName);
        baseHost = embedded.createHost(hostName, "webapps");
        baseEngine.addChild(baseHost);
        // RootContext
        context = addContext("", "ROOT");
        // ManagerContext
        context = addContext("/manager", "manager");
        context.setPrivileged(true);
        // add new Engine to set of Engine for embedded server
        embedded.addEngine(baseEngine);
        // create Connector
        httpConnector = embedded.createConnector((java.net.InetAddress) null,
            portNumber, false);
        // add new Connector to set of Connectors for embedded server, associated
        // with Engine
        embedded.addConnector(httpConnector);
      public void start()
        // start server
        try
          embedded.start();
        catch (org.apache.catalina.LifecycleException ex)
          ex.printStackTrace();
          //fileLog.log("Startup failed");
          //fileLog.log(ex.getMessage());
      public Context addContext(
        String path,
        String docBase)
        Context c;
        c = embedded.createContext(path, docBase);
        baseHost.addChild(c);
        return c;
      public static void main(String[] args)
        new EmbeddedTomcat("test", 8080).start();
    }Let me know if you have any problems.
    /klejs

  • How to attach a file to tomcat server using SERVLETS

    Hello friends,
    I want to enable users to attach a file and send it to my server. This is a very common feature seen anywhere like e-mail attachments.
    Iam using tomcat server. I tried HTTP put but it did not work.
    Please give some suggessions.
    Thanks
    Goldy

    check this url:
    http://www.servlets.com/cos/index.html
    follow the link MultiPartRequest
    Spieler

  • Where to place HTMl files in  tomcat while executing Servlets examples ?

    Hi,
    I'm learning servelets (HttpServlets). in that input is given through html files.now i dont know where to place that html file in apache tomcat server
    This is my Directry Structure
    Java's ---- C:\Program Files\Java\jdk1.5.0\bin
    Tomcat's--C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ThreeParams extends HttpServlet
    public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Reading Three Request Parameters";
    String docType ="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +"Transitional//EN\">\n";
    out.println(docType +"<HTML>\n" +"<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +"<BODY BGCOLOR=\"#FDF5E6\">\n" +"<H1 ALIGN=\"CENTER\">" + title + "</H1>\n" +"<UL>\n" +" <LI><B>param1</B>: "+ request.getParameter("param1") + "\n" +" <LI><B>param2</B>: "+ request.getParameter("param2") + "\n" +" <LI><B>param3</B>: "+ request.getParameter("param3") + "\n" +"</UL>\n" +"</BODY></HTML>");
    }HTML code ---
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>Collecting Three Parameters</TITLE></HEAD>
    <BODY BGCOLOR="#FDF5E6">
    <H1 ALIGN="CENTER">Collecting Three Parameters</H1>
    <FORM ACTION="ACTION="C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\root\WEB-INF\classes.ThreeParams">
    First Parameter: <INPUT TYPE="TEXT" NAME="param1"><BR>
    Second Parameter: <INPUT TYPE="TEXT" NAME="param2"><BR>
    Third Parameter: <INPUT TYPE="TEXT" NAME="param3"><BR>
    <CENTER><INPUT TYPE="SUBMIT"></CENTER>
    </FORM>
    </BODY></HTML>
    {code}
    servlet code is compiling without any errors, now where should i place the class file and html file in tomcat to execute this program..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    webapps\yourapplicationname\WEB-INF\

  • Help with Error on tomcat and java servlet

    i've just recently installed Dialect Payment client onto my server and is using Java to correspond with the server. I can run the diagnostic test run perfectly fine but when I have compiled the form and the app, I keep getting the error:
    javax.servlet.ServletException: Invoker service() exception
         org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:478)
         org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         filters.ExampleFilter.doFilter(ExampleFilter.java:149)
    root cause
    com.qsipayments.utility.AssertionError: InvalidConfigException can only be thrown on reload
         com.qsipayments.utility.Assert.shouldNotReachHere(Assert.java:246)
         PaymentClient.util.PCConfigurationService.getConfiguration(PCConfigurationService.java:72)
         com.qsipayments.utility.logging.Logging.initialise(Logging.java:198)
         PaymentClient.PaymentClientBase.initialiseLogging(PaymentClientBase.java:1179)
         PaymentClient.PaymentClientBase.<init>(PaymentClientBase.java:106)
         PaymentClient.PaymentClientImpl.<init>(PaymentClientImpl.java:26)
         Java_3DS_3P_AuthPay_DO.doPost(Java_3DS_3P_AuthPay_DO.java:116)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:420)
         org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         filters.ExampleFilter.doFilter(ExampleFilter.java:149)
    If anyone can help or advise me on this matter, it would be incredibly fantastic! I've tried asking the people who have provided me with the program but they dont seem to have anything useful that i can do to fix the error. I was told by my server admin that it was in the coding, but they claim that it has nothing to do with the coding.
    PLEASE HELP.I've been working on this for months and about to die from frustration!

    I haven't worked with this vendor product, but here are some ideas you might find useful:
    It appears is a configuration problem when using the vendor software (but they already told you that, didn't they!!!).
    I say the above because these lines in your printout are from vendor supplied objects (that you didn't create):
    com.qsipayments.utility.AssertionError: InvalidConfigException can only be thrown on reload
    com.qsipayments.utility.Assert.shouldNotReachHere(Assert.java:246)
    PaymentClient.util.PCConfigurationService.getConfiguration(PCConfigurationService.java:72)
    I suggest creating a brand new project with the simplist use of the above vendor project and get it to work.
    You can use the vendor's (on line) documentation to do this. Deploy it in production to ensure there are no deployment issues. Work closely with one of
    your fellow employees (more than one pair of eyes can pick up stuff that you miss). Next, look at what features of the vendor software the originial project uses and what features the sample project uses. Try to implement a subset of functionality of the orginial project into the sample project and get that to work. Implement the next feature, test, etc. Do small experiments at a time so you can easily isolate what doesnt work.
    If none of the above works for you, try contacting the manufacturer or thier support web site. If none of the above works, look into using a compeditors product.

Maybe you are looking for