Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Stop Tomcat cleanly using Ant

Posted on 2003-12-05
12
Medium Priority
?
1,415 Views
Last Modified: 2013-11-24
Hello,
As part of my ANT build script I need to shut down tomcat, clean some stuff up then do a clean deployment.  I stop tomcat with the following target.

<!-- Stop Tomcat -->
    <target name="stop.tomcat">
        <java classname="org.apache.catalina.startup.Bootstrap" fork="yes">
            <jvmarg value="-Dcatalina.home=c:\tomcat" />
            <arg value="stop" />
            <classpath>
                <fileset dir="c:\tomcat">
                    <include name="bin/bootstrap.jar" />
                </fileset>
            </classpath>
        </java>
    </target>

This stops the server but leaves the window open.  The final line in the window says
[java] Stopping service Tomcat-Standalone.  If I navigate to the server it seems to be shut down.

Problem is that when my script goes to clear out the shared/lib folder on tomcat I get the following error:
BUILD FAILED
file:C:/cruisecontrol/work/build.xml:169: Unable to delete file T:\shared\lib\ac
tivation.jar

(I don't think the problem has anything to do with activatipon.jar specifically its just the first alphabetically)

If I close the tomcat window manually the problem goes away.  Any idea on how I can shut down cleanly using ANT.

Thanks in advance.
Bruce


0
Comment
Question by:bqchristie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9883103
Could you use the exec task to call the shutdown.bat file?

<exec dir="${tomcat_bin}" executable="shutdown.bat" os="Windows 2000" output="dir.txt">
</exec>

(or something like that ;-))
0
 

Author Comment

by:bqchristie
ID: 9883117
Thanks for the thought.  Unfortunately I tried that and get basically the same result.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 9883122
>>Unable to delete ...

Are any of those files/libraries in use by the stop.tomcat task?
0
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 

Author Comment

by:bqchristie
ID: 9883142
That's an interesting thought.  May well be.  Let me investigate a little and I will get back to you.

Thanks
Bruce
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9883151
Do you need a pause in the ant script to give Tomcat time to actually stop?
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9883240
I don't know if I can help much further.  The following ant script works fine on my system:

<?xml version = '1.0' encoding = 'ISO-8859-1' ?>
<project name="TomcatStopper" default="killit">
  <target name="killit">
    <exec executable="/var/tomcat5/bin/shutdown.sh" os="Linux" output="shutdown.txt">
    </exec>
  </target>
</project>

However, there are some obvious differences ;-)  I'm using Linux and I also suspect that you're running Tomcat 4.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9883259
>> Are any of those files/libraries in use by the stop.tomcat task?

If this was the problem, then a different error would have been reported using the exec task (I *think* ;-))

Does "basically the same result" mean exactly the same result?
0
 

Author Comment

by:bqchristie
ID: 9883295
Exaclty the same I am afraid.  Unforunately re:

>> Are any of those files/libraries in use by the stop.tomcat task?

Seemed plausible as I had duplicate jars in shared\lib and common\lib  but I still have the same problem after removing them.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9883330
So you're now 100% certain that any files you're trying to delete are not in use by Ant itself?
0
 

Author Comment

by:bqchristie
ID: 9883358
No, actually I think you ARE onto something I just need some time to test a couple of things.  I just want to make sure i can re-create the problem consistently and fix it with your solution.  At first glance it seemed to not work but there are three apps all with there own libs and several dupe jar files.  
0
 

Author Comment

by:bqchristie
ID: 9883465
Thanks for your help guys.  Turns out:

>>Are any of those files/libraries in use by the stop.tomcat task?

was the problem.

Thanks again
Have a good weekend.
Bruce
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9883500
8-)
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question