Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start and stop jboss server using Ant task?

Tags:

jboss

ant

I need to stop, deploy my ear file and start Jboss server using the Ant tasks.

I am able to compile, build and deploy my J2EE application as an ear file into the JBoss server successfully using Ant tasks. We can see the redeployment of my application in the jboss console. I want to stop the server before deployment and start the server.

Is there any way to do this ?

like image 858
Puru Avatar asked Oct 14 '22 04:10

Puru


1 Answers

Here how you start/stop JBoss app container including deploy an application :

<!-- Stop Jboss -->
<target name="stop-jboss" description="Stops back-end EJB container" >
    <exec executable="${jboss.bin.dir}/shutdown.bat" spawn="true">
        <arg line="-S" />
    </exec>
    <echo>+-----------------------------+</echo>
    <echo>| J B O S S   S T O P P E D   |</echo>
    <echo>+-----------------------------+</echo>
</target>

<!-- Start Jboss -->
<target name="start-jboss" description="Starts back-end EJB container" >
    <exec executable="${jboss.bin.dir}/run.bat" spawn="true">
    </exec>
    <echo>+-----------------------------+</echo>
    <echo>| J B O S S   S T A R T E D   |</echo>
    <echo>+-----------------------------+</echo>
</target>

<!-- deploy target-->
<target name="deploy-war" description="deploy war file" depends="prepare">
  <sequential>
    <antcall target="stop-jboss" />
    <war destfile="${file.name}" webxml="conf/web.xml">
       <classes dir="bin" />
    </war>
    <antcall target="start-jboss" />
        <echo>+----------------------------+</echo>
        <echo>|   W A R  D E P L O Y E D   |</echo>
        <echo>+----------------------------+</echo>
  </sequential>
</target>

Hope this is helpful :)

like image 51
Simple-Solution Avatar answered Oct 18 '22 22:10

Simple-Solution