Using a Tomcat Lifecycle listener (.../catalina/Lifecycle.html) sounds like exactly what you want. This from http://www.atomikos.com/Documentation/Tomcat55Integration33 illustrates illustrates the use:

public class AtomikosLifecycleListener implements LifecycleListener {
private static Log log = LogFactory.getLog(AtomikosLifecycleListener.class);

   private UserTransactionManager utm;

   public void lifecycleEvent(LifecycleEvent event) {
      if (Lifecycle.START_EVENT.equals(event.getType())) {
         if (utm == null) {
log.info("starting Atomikos Transaction Manager " + Configuration.VERSION);
            utm = new UserTransactionManager();
         }
      }
      else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
         if (utm != null) {
            log.info("shutting down Atomikos Transaction Manager");
            utm.close();
         }
      }
   }
}

Hope this helps.

On Feb 11, 2010, at 7:15 AM, Jan Van Besien wrote:

Pid wrote:
On 11/02/2010 11:15, Jan Van Besien wrote:
Hi all,

I'm using tomcat-6.0.18 with java-1.6.0-18 on ubuntu-9.10.

We are using the tanuki service wrapper to run tomcat as a linux
service, more or less as described in [1].

We also have a monitoring mechanism which checks the "health" of the
running tomcat with all the applications deployed into it by making
certain well choosen http requests that test some core functionality of our applications. If some of this fails, a system is in place to have
another redundant server (with another tomcat) take over.

Now the problem is that we only want the monitoring mechanism to start monitoring after tomcat is completely started (successful or not). So I would like to know what my options are to "ask" a running tomcat if it
has more startup/deployment work to do, or if it is finished.

The log files contain things like "INFO: Server startup in 39188 ms", so clearly tomcat knows this information. I could ofcourse parse the log files, but I would prefer a more robust mechanism. Maybe a java API, or
JMX or something like that?
How do you define "completely started"? E.g. The server might start but the applications not start.

I agree this is a subtile question, but whatever makes tomcat decide to log "Server startup in xxx ms" is good for me. Note that it also logs this if one of the deployments failed.

Apart from JMX, there a number of things you can do within the server and each application that could lead to a notification. Implement a ServletContextListener for an application, or a LifecycleListener for the server.

I don't want anything in my applications per se, because when tomcat fails to deploy one of my applications (for whatever reason), I still want to know that tomcat is finished "trying" to deploy my applications.

Kind regards
Jan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to