I've written an ant task to invoke mbean operations and
set mbean attributes. This can be used among other
things to deploy and redeploy applications and
subpackages from your ant build file.
To use, put these in your ant/lib directory:
jboss-common-client.jar
jboss-j2ee.jar
jboss-system-client.jar (needed only if you expect
DeploymentExceptions)
jbossjmx-ant.jar (from varia/output/lib)
jnet.jar
Here is an example of some deploy/redeploy targets:
<!-- this deploys the myear.ear from where you built it
as an
exploded package, with directories instead of jar files.
Note myear.ear and myejbs.jar are directories, not
jar files-->
<target name="remote-deploy" if="remote.deploy">
<taskdef name="jmx"
classname="org.jboss.ant.JMX"/>
<!-- look in jndi view for what
org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl is bound under-->
<jmx adapterName="jmx:HP.home.home:rmi">
<propertyEditor type="java.net.URL"
editor="org.jboss.util.propertyeditor.URLEditor"/>
<invoke
target="jboss.system:service=MainDeployer"
operation="deploy">
<parameter type="java.net.URL"
arg="file:${unpacked.build.dir}/myear.ear/"/>
</invoke>
</jmx>
</target>
<!-- This redeploys an ejb jar inside the ear we just
deployed -->
<target name="remote-ejb-redeploy">
<taskdef name="jmx"
classname="org.jboss.ant.JMX"/>
<jmx adapterName="jmx:HP.home.home:rmi">
<propertyEditor type="java.net.URL"
editor="org.jboss.util.propertyeditor.URLEditor"/>
<invoke
target="jboss.system:service=MainDeployer"
operation="redeploy">
<parameter type="java.net.URL"
arg="file:${unpacked.build.dir}/myear.ear/myejbs.jar/"/>
</invoke>
</jmx>
</target>
The ant task is available in both 3.0.1 and 3.1 cvs.
The redeploy method and a bug workaround are only in
3.0.1 at the moment.