File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Restarting Tomcat service on a remote machine from Hudson Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Restarting Tomcat service on a remote machine from Hudson" Watch "Restarting Tomcat service on a remote machine from Hudson" New topic
Author

Restarting Tomcat service on a remote machine from Hudson

AmitDBond Sethi
Greenhorn

Joined: Jun 06, 2008
Posts: 11
Hi,

We are using Hudson as CI tool. Our requirement is such that, If the build is successfull in hudson, we want to deploy the application war to a tomcat service.
The tomcat service and Hudson are running on different machines (devserver2 and devserver1 respectively) in the same network. For this purpose, I have created an ant script which stops the tomcat service, copy the war in the webapp directory and then start the tomcat service again.
The ant script I have written are like this (only stop and start service targets are mentioned here).

<target name="stoptomcatdevsvr2" description="Stops the ${service}">
<exec executable="sc.exe">
<arg value="\\goshcc-devsvr2"/>
<arg value="stop"/>
<arg value="tomcat6"/>
</exec>
</target>

<target name="starttomcatdevsvr2" description="Stops the ${service}">
<exec executable="sc.exe">
<arg value="\\goshcc-devsvr2"/>
<arg value="start"/>
<arg value="tomcat6"/>
</exec>
</target>

Every thing works fine if the ant is executed out side the Hudson. But when I execute the ant using Hudson's Ant configuration, I get the below problem.

stoptomcatdevsvr2:
[exec] [SC] OpenService FAILED 5:
[exec]
[exec] Access is denied.
[exec]

devserver1 has access to start/stop services at devserver2 remotely. This I am 100% sure as I can execute below commands from the command prompt.

sc \\goshcc-devsvr2 stop Tomcat6
sc \\goshcc-devsvr2 start Tomcat6

I am not sure why the same ant does not work when running under Hudson.
Can someone please help me.

Thanks and Regards,
Amit Sethi
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
I wonder why you are not using this Executing Manager Commands With Ant
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Restarting Tomcat service on a remote machine from Hudson
 
Similar Threads
Starting Tomcat from ANT
Which IDE support JSP 2.0
Problem with catalina.sh
ANT script running a WIN cmd with start??
Stop/Start Tomcat within eclipse