Building

Building the package requires Maven and a working copy of JBoss. The principle allows other containers accepting JMX calls to be used but that would require probably some modification in source code and build files.

The build process is a typical Maven one with just one special requirement: The variable com.maxiq.tools.jboss.home has to be defined (e.g. in build.properties) to the root dir of a working JBoss installation. For example, you can try something like:

com.maxiq.tools.jboss.home = e:/jbosstc

in your build.properties file, presuming your JBoss is installed in e:\jbosstc.

When building (with tests), a JBoss instance running in the specified home has to be already running. The build process had been tested on Windows 2000, with JDK 1.3.1_02 and JBoss 3.2.1. If this is not your setup, your mileage may vary.

Using with Ant

In order to use the package with Ant you have to cover the following steps:

  • Place the binary jar somewhere Ant classloader can reach it (runtime specification is OK).
  • Place a taskdef inside your build file along the following sample:

                    <taskdef name="jbosswait"
                        classname="com.maxiq.tools.jboss.JMXDeploymentMonitor" >
                       <classpath>
                          <fileset dir="lib" includes="jbossjmx*.jar" />
                       </classpath>
                    </taskdef>
                 

    Note the fact that our jbossjmx jar location is explicitly specified.
  • When you want to wait for a particular deployment or undeployment to happen manipulate the files (copy or delete) within JBoss directory and the use the defined task to wait for the completion. One example is given below:

                    <!-- copy the new WAR in JBoss's deploy directory -->
                    <copy file="myapp.war" todir="${the.jboss.deploy.dir}"/>
                    <!-- wait for deployment to happen -->
                    <jbosswait jbhome="${the.jboss.home.dir}"
                      jndiurl="jnp://localhost:${the.jboss.jndi.port}"
                      file="${the.jboss.deploy.dir}/myapp.war"
                      timeout="60000" wantedStatus="true" />
                    <!-- continue processing; the WAR is deployed -->
                 

    Please note that the property the.jboss.home.dir should point to the JBoss home dir (i.e. the one containing bin, client, server,...), the property the.jboss.jndi.port should be the port where JNDI listens (normally 1099) and the property the.jboss.deploy.dir should be the JBoss deploy directory. Specifying JNDI URL might be required when several JNDI providers are available and your JBoss does not sit behind localhost:1099.

    You may also monitor the status of jboss-service.xml file to wait for full startup of JBoss. In case you do that (i.e. start JBoss than wait for its start) then you should introduce some blind 5 - 10 seconds wait to allow JBoss JMX system to start. Otherwise the jbosswait task will fail for lack of partner to talk with.

Using with Maven

When using in Maven the approach is to use the be an through Jelly code. Here is one example:

         <j:useBean var="jmxbean" class="com.maxiq.tools.jboss.JMXDeploymentMonitor"
            jbhome="${the.jboss.home.dir}"
            file="${the.jboss.deploy.dir}/myapp.war" timeout="60000"/>
         <j:set var="jbossRunning" value="${jmxbean.isServerAlive()}" />
         <j:if test="${jbossRunning}">
            <echo>Current deployment status: ${jmxbean.isDeployed()}</echo>
         </j:if>
All properties are similar to those used in Ant.

The above example checks if the server is running and if so, it shows the deployment status of myapp.war.

Using in other environments

Using the package in othe environments is possible, because it is basically a bean. You should instantiate the bean, set the required properties, then use its methods to interact with the JBoss instance with respect to the deployment status of things. If you want to use this approach, then please consult the Javadoc.