Perform action when Tomcat start and stop

Hi. I'd read a thread about performing an action when Tomcat starts with configuring the web.xml file. I just wonder whether it's probable or not to perform an action when the Tomcat is stop. I mean like when the Tomcat is called to stop it'll run a class or call a servlet first before it's finally shut down. Is it possible to do that???
Thanx!

It should by possible with a Listener. You can see the use within the server.xml with the ServletLifecycleListener.
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
Look into the LifecycleListener Interface from the source and the implementations. I see some samples with mBeans using this interface.
Examples:
http://rollerweblogger.org/page/roller/20040625
I 'have never try it out, but it should work like described!
regards Dietmar

Similar Messages

  • Need help getting Tomcat 5.0.28 to start (and stop, eventually)

    Hi!
    I am such a newbie to the Terminal and writing scripts, so please forgive my naiveté. I have successfully installed Tomcat in my /usr/local directory, but I am having trouble creating files to start and stop Tomcat, per the instructions on the following page:
    http://developer.apple.com/internet/java/tomcat1.html
    I've followed the directions but continue to get the following error after I execute ~/bin/start_tomcat.
    -bash: start_tomcat: command not found
    My file contains the following code:
    #!/bin/sh /n
    export CATALINA_HOME=/usr/local/jakarta-tomcat-5.0.28 /n
    export JAVA_HOME=/usr /n
    $CATALINA_HOME/bin/startup.sh /n
    If anyone can help me, I would really, really, really appreciate it!
    Thanks!
    PowerBook G4 12"   Mac OS X (10.4.5)  

    Why are there all those "/n" there? Either you or the place you copied from has the wrong slash. But still, it's wronger than that to have them at all: "\n" means a newline (i.e., press "return") not the actual "backslash en" characters. Sometimes people post code with those \n visible: by making it explicit where a line-break should be, one doesn't have as much trouble when a web browser reformats the text and puts line breaks where they don't belong.

  • VMM 2012: How to Configure Automatic Start and Stop Actions for a Virtual Machine?

    Does somebody know how to confgure Automatic Start and Stop Actions for a Virtual Machine in VMM 2012?
    I miss that option.

    Automatic Start or Automatic Restart actions are available for virtual machines running on a Hyper-V cluster from within Virtual Machine Manager.
    From within Virtual Machine Manager, bring up the Virtual Machine's properties:
    Click "Hardware Configuration"
    Click "Availability"
    Click "High", "Medium", or "Low" to enable automatic start/restart or
    Click "Do not restart automatically" to disable automatic start/restart
    Screenshot from VMM 2012 for a VM running in a Server 2012 R2 Hyper-V cluster:
    VMs running on a cluster have to be marked "Highly Available" and logically, Microsoft assumes that you'll want these VMs to be running all the time when this setting is selected.  If the cluster fails or needs to be restarted, you can set the priority
    by which a VM restarts, or you can set the VM to not restart at all when cluster services are restored by using the settings above.

  • Action Script 3 code not working for start and stop button?

    Ok so I have this simple animation I created of a circle that moves from one side of the stage to the other. I have added a new layer and called it buttons. On this layer I have added 2 buttons. One for start and another one for stop. The purpose is to get my circle to move from one side of the stage to the other but be able to use my buttons so that I can start and stop the animations at random times during playback. I fixed all my compiler errors now the problem lies in that everytime I click the start or the stop button I get an output error. I have a 3rd layer in which is titled actions and this is where all my code is posted. I removed that layer and placed my code in the first frame of the buttons layer to see if this would change anything but I still get the same output errors. So I just added back my actions layer. What could I be doing wrong? I have made sure to name all my movie clips and buttons correctly and I even added an instance name to them.
    Here is my code and the errors I am getting when I press the play and stop button on test-
    start_btn.addEventListener(MouseEvent.CLICK, startCircle);
    stop_btn.addEventListener(MouseEvent.CLICK, stopCircle);
    function startCircle(e:MouseEvent):void{
        circle.play();
    function stopCircle(e:MouseEvent):void{
        circle.stop();
    green_btn.addEventListener(MouseEvent.CLICK, greenCircle);
    red_btn.addEventListener(MouseEvent.CLICK, redCircle);
    function greenCircle(e:MouseEvent):void{
        circle.play();
    function redCircle(e:MouseEvent):void{
        circle.stop();
    Here are my output errors-
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at exercise2_fla::MainTimeline/redCircle()
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at exercise2_fla::MainTimeline/greenCircle()

    ok so my circle is my movie clip and it is titled circle and the instance name is circle. Am I supposed to change MovieClip to circle? I put the code at the top of my actions script but for some reason it did not work. I did change play to stop and it got the movie clip to stop when I do test movie but my buttons still do not work. So I changed stop back to play. Strange.
    I did try changing MovieClip to circle but that did not work so I did Circle with a capital C and that did me no good eigther.
    I meant to add that I did get an error that said- 1180 Call to a possibly undefined method circle.

  • HT6058 I have updated my I pad dut I'm still having problems my iPad seems to freeze and when I go to put in my pin it take a few seconds before the numbers go in and my games stop and start and stop and start for a bit before they run properly

    I have updated my I pad dut I'm still having problems my iPad seems to freeze and when I go to put in my pin it take a few seconds before the numbers go in and my games stop and start and stop and start for a bit before they run properly

    Try this  - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.) No data/files will be erased.
     Cheers, Tom

  • When watching videos it will start and stop.

    when watching vids it will start and stop. what causes it to do this? wondering.
    This question was solved.
    View Solution.

    sdh1975 wrote:
    when watching vids it will start and stop. what causes it to do this? wondering.
    Hi,
    Are you talking about online or offline ? If online, the connection speed may be not fast enough.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • I am trying to create a ringtone, when I right click and and go to get info I can't open anything under options. Itunes is not allowing me to do anything under options including changing the start and stop times. ??

    I am trying to create a ringtone, when I right click and and go to get info I can't open anything under options. Itunes is not allowing me to do anything under options including changing the start and stop times. ??

    GarageBand '11 - Create an iPhone ringtone - Apple Support

  • How to eliminate the "Ping" sound when starting and stopping videoing

    How to eliminate the "ping" sound when starting and stopping a video on iPhone.  Thanks.

    I asked my friends on Facebook and one came up with the answer... I just had to flip the little "ring-silent switch" on the side of the iPhone to cut the "Pinging" sound!  There's probably another way but this works!

  • Pops when starting and stopping

    I thought that this issue might be related to my m- audio firewire, but i disconnected it and there still occurs a slight static 'pop' when i start or stop a track w/ the space bar. If anyone has had this experience or has any insight to this kind of thing please help...

    Thank you, sir. I muted my audio regions and it seemed to considerably decrease this 'popping'. However, I tried this on a piece with multiple midi tracks and it's still pretty evident, especially moving the pointer around. I am mainly concerned if there is something either wrong with my electric setup or something otherwise damaging, but it is annoying as well... thanks again for your reply.

  • Report on active sync actions (like starting and stopping the sync)

    Is there a way to report on who stopped or started an active sync? I'm guessing it has to be stored somewhere, but I can't find it.
    Thanks!

    Hi Smit,
    I believe you are talking about FMS AWS instance and you may be using a centos 4.0.2 instance AMI or lower?
    Well ... earlier,  options for stopping a centos AWS image was not available, but recently they are there in place, so I suppose if you use a new centos 4.5.1 AMI then probably you can start stop the aws instance on yuor will. Give ut a shot and let me know.
    Regards,
    Shiraz Anwar
    I again cross-checked and found that you were right, start and stop is not supported there .... an alternative method is to take a snapshots of the runinng instnace and terminate that instance after that, later you can use your snapshot to attach to the EBS volume to run your system again. You may need to use the Elastic IP address, because you wont like your users to update each time you terminate the old instance, and create new instance from snapshot. I have never used it in this way, but this is one of the approach.

  • When I acquire data using USB6008 and NI_DAQmx Base in VC++, Shall I start and stop the task in ONTimer function?

    void Ctest2Dlg:nTimer(UINT nIDEvent)
       DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
       DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByScanNumber,data,100,&pointsRead,NULL));
      DAQmxBaseStopTask (taskHandle);
    If I do this, the program will halt in about half minute. But if I do not start and stop task in OnTmer function, the program will not halt and the data acquired is not corrected.
    Please help me! Thanks

    This is a duplicate post.  Please post any new replies to the linked forum.
    Samantha
    National Instruments
    Applications Engineer

  • Start and stop a loop automatica​lly subtractin​g at each iteration

    Hi there,
    I know that there are some topics about it, but I could not find any solution, especially because I use the version 7.1 and cannot open new version files.
    My problem is as follows:
    I need to charge a tank from 6 to 10 in the morning, every day during 3 days. The process must start and stop automatically, which means, no bottoms to start or stop. The start and stop conditions come from the hour.
    I start with a big loop of 72 iterations, which corresponds to 72 hours.
    The tank must start at level 6 every time it starts.
    After the start, 1 unit must be subtracted in each iteration. Which means, that at 6 am the tank has level 10, at 7 am level 9 and so on. In the end, at 10 am the tank level is equal to 2.
    In the next day, the process must start again and the tank must start at level 6.
    Any suggestions? Thanks in advance.
    Solved!
    Go to Solution.

    While this may work it can be improved significantly. This really isn't a state machine. This is basically the same as your flat sequence with the exception of using a While loop with a Case statement to implement each frame.
    You should define what your actions are and create a typedefed ENUM naming them. State names of 1 through 24 are meaningless. Not to mention in your code many of the cases are duplicates of others. That would mean that all of those can be one state with logic to determine what action/state comes next. A properly defined state machine would not need the outside For loop. Without knowing your specific needs some examples of reason state names would be the following: Start, Stop, Exit, Error, Initialize, Get Tank Level, Fill Tank, Drain Tank, Idle, etc. Can you see how these are easier to understand than 1 through 24.
    There are lots of examples of state machines here. Try a search and take a look at some of them.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • My ipod nano 7th gen. won't save the changes I make to a song's start and stop time. How do I fix this?

    So I have a few songs that I don't like the intro to or the end of it that I had cut to where I wanted on my previous ipod. When I try to do the ame thing with this one with the start and stop time, it will work for awhile and then randomly start and stop where it had originally. I have done it like 4 times now for some songs and I can't seem to get it to stick. Suggestions?

    If you use the Sync feature in iTunes, then it needs to be done to the song in your Music Library, then synced with the iPod.  If you do not use the Sync feature and are performing the changes to the song on your iPod specifically, then the setting may be getting overwritten when you drag the song that's already on the iPod back onto the iPod.  It will overwrite all local settings for the song on the iPod with the settings in your library. 
    Try performing the changes to the song in your music library, and then dragging it back over to your ipod (or Sync your iPod if you use that feature).  This will make sure that the setting are consistent in both your library and iPod in-case you were to ever overwrite the song once more.

  • Batch file to start and stop services

    I've setup a CF Probe on my Development Server to ensure my
    CF Production server is up and running (services = Apache and CF
    Application Server). It checks the PROD login page and if it times
    out in 30 sec the probe fails. I understand I can execute a file
    (batch file with net start and net stop) but the problem is I need
    to have the probe somehow point to the .bat file on the PROD server
    and not on the local machine. How can I remotely access this batch
    file and execute it? I don't know how to point to the file on the
    other server... can anyone help?

    Hi Ken,
    You had pointed me in the right direction regarding the
    psstools in order to create a batch file that can remotely start
    and stop services.
    i used the psexec command and am able to successfully restart
    the services needed remotely... however when i pick the file in the
    coldfusion administrator (in the probes section) how to i point to
    the batch file to run? it seems like the probe is not running the
    script like i want... the file is located on the c:\ so i entered
    c:\test2.bat...
    Thanks,
    Matt
    Matt,
    You should review the online help in the cfadmin for probes
    and the links it points you to in the developer's guide. Basically
    you need to define a new probe in the cfadmin by clicking the
    "Define New Probe" button. One of the probe's attributes will be
    what action. Define the action as a program and point it at a batch
    file running psexec. You will probably need to run CFMX as a
    specific user and not as localsystem, which is the default.

  • How to start and stop a server

    I am doing some sockets programming.
    Now, when I want to get the TomCat 4 server running for instance, I would have to run the startup.bat or startup.sh file. To stop the server I run the shutdown.bat or shutdown.sh file.
    Can I do the same thing in Java?
    That is, in one window, I run a program: C:\>java myserver start
    The server starts running and holds there.
    In another window, I run another command: C:\>java myserver stop
    and the server in the other window stops.
    I am thinking the server would be running in a thread. When I shut it down, I close the thread just like in the Applet Clock example.
    I've tried this but it doesn't work.
    Can anyone please advise.
    Thanks.
    Anthony.

    Not precisely that way, but just off the top of my head, you would have to have a handle to the proccess (server) in the first window, then have a monitor program that allows you take this handle and end it. I would make this monitor program be the gateway to starting and stopping your server. To run a .bat file you can use runtime.exec().

Maybe you are looking for