Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Restarting Tomcat service on a remote machine from Hudson

 
AmitDBond Sethi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder why you are not using this Executing Manager Commands With Ant
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic