Over the years J2EE has become a matured technology. Several vendors have come up with their J2EE complaint application server. Jboss one of them, it is an opensource J2EE complaint application server.
This tip is about starting and stopping Jboss, j2ee compliant application server, from within apache ant script.
1. First define the required properties
<property name="java.home" value="C:/Program Files/Java/jdk1.5.0_06"/>
<property name="jboss.home" value="D:/javadev/jboss-4.2.1.GA/"/>
<property name="jboss.port" value="1198" />
<!-- JBoss server's JNDI (naming) service runs on port 1099
by default. Port 1198 wil be used by shutdown option, don't
change to any other port used by Jboss internally
-->
<property name="jboss.host" value="localhost" />
<property name="deploy.configuration" value="all" />
<property name="deploy.configuration.dir"
value="${jboss.home}/server/${deploy.configuration}/conf"/>
<echo message="==========================================="/>
<echo message="Java home has been set to: = ${java.home}"/>
<echo message="JBoss home has been set to: = ${jboss.home}"/>
<echo message="Server option used is ${deploy.configuration}"/>
<echo message="==========================================="/>
<property name="jboss.home" value="D:/javadev/jboss-4.2.1.GA/"/>
<property name="jboss.port" value="1198" />
<!-- JBoss server's JNDI (naming) service runs on port 1099
by default. Port 1198 wil be used by shutdown option, don't
change to any other port used by Jboss internally
-->
<property name="jboss.host" value="localhost" />
<property name="deploy.configuration" value="all" />
<property name="deploy.configuration.dir"
value="${jboss.home}/server/${deploy.configuration}/conf"/>
<echo message="==========================================="/>
<echo message="Java home has been set to: = ${java.home}"/>
<echo message="JBoss home has been set to: = ${jboss.home}"/>
<echo message="Server option used is ${deploy.configuration}"/>
<echo message="==========================================="/>
2. Define Jboss's start target
<target name="jboss.start" description="Start the JBoss server." >
<java dir="${deploy.configuration.dir}" classname="org.jboss.Main"
fork="true">
<arg line="-c ${deploy.configuration}"/>
<jvmarg value="-Xms512m"/>
<jvmarg value="-Xmx1024m"/>
<classpath>
<pathelement path="${jboss.home}/bin/run.jar"/>
<pathelement path="${java.home}/lib/tools.jar"/>
</classpath>
</java>
</target>
<java dir="${deploy.configuration.dir}" classname="org.jboss.Main"
fork="true">
<arg line="-c ${deploy.configuration}"/>
<jvmarg value="-Xms512m"/>
<jvmarg value="-Xmx1024m"/>
<classpath>
<pathelement path="${jboss.home}/bin/run.jar"/>
<pathelement path="${java.home}/lib/tools.jar"/>
</classpath>
</java>
</target>
3. Define Jboss's stop target
<target name="jboss.stop" description="Stop the JBoss server." >
<java dir="${deploy.configuration.dir}" classname="org.jboss.Shutdown" fork="true">
<arg line="${jboss.host} ${jboss.port} -u admin -p admin"/>
<classpath>
<pathelement path="${jboss.home}/bin/shutdown.jar"/>
</classpath>
</java>
</target>
<java dir="${deploy.configuration.dir}" classname="org.jboss.Shutdown" fork="true">
<arg line="${jboss.host} ${jboss.port} -u admin -p admin"/>
<classpath>
<pathelement path="${jboss.home}/bin/shutdown.jar"/>
</classpath>
</java>
</target>
0 Responses to How to startup and stop J2EE application server from Apache ANT
Something to say?