2 Replies Latest reply on Feb 23, 2004 10:07 AM by Tom Baeyens

    ant task for deploying ?

    Tom Baeyens Master

      With a quick scan on the net and the forums I could not find anything about an ant task that deploys a package to the jboss deploy dir and waits till deployment is finished.

      For web-application deployments, I can use the ant-wait-task and specify a static unsecured page of the web-app. (although I'm not quite happy with this approach because I don't always have a static page)

      But for ejb-module deployments (or .ear's without a web-app) I don't now a better solution then throwing the jar file in the deployment dir, wait for a few seconds and hope for the best.

      The idea I have in mind is write an ant task like http://ant.apache.org/manual/OptionalTasks/serverdeploy.html for jboss and a corresponding deployment-listener-module (web-app?) that is deployed in jboss. The ant task would then register itself with the deployment-listener-module. The deployment-listener-module registers itself with the JMX registry to get notified of the deployment.

      Being lazy and all... somehow I got the feeling that there's got to be an easier way. Maybe even somebody else did it already or knows the easier solution. Now *that* would be geat :-)

      Tom Baeyens

      btw : congrats with the venture capital !

        • 1. Re: ant task for deploying ?
          Mike Finn Apprentice

          I have a similar dilemma, as I want to run some junits once everything is deployed. I have not had time to try yet, but one idea I had was to use jmx-console/html adapter to get the URL (via ant wait) for the installed EAR? Not sure what mbean gets deployed last in an EAR, but this one may be it:


          Admittedly a hack, and certainly not as slick as your suggestion. The JMX solution might be as simple as the ant task registering and listening to JMX notifications for a deployment-completed for the appropriate module. Not sure if there is such a notification, but it doesn't seem too big of a deal to implement.

          • 2. Re: ant task for deploying ?
            Tom Baeyens Master

            I created a servlet that does a deployment and waits for the deployment to complete. The servlet takes as input a parameter called 'url'

            2 questions :
            1) Do you see any potential problems with this solution ?
            2) Do you have a simpler solution ?

            Servlet code

            package org.jbpm.ejb.deploy;
            import java.io.*;
            import java.util.*;
            import javax.management.*;
            import javax.servlet.*;
            import javax.servlet.http.*;
            public class DeployServlet extends HttpServlet {
             private static List deployed = new ArrayList();
             protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
             String url = request.getParameter("url");
             try {
             ObjectName objectName = new ObjectName("jboss.system:service=MainDeployer");
             Object[] args = new Object[] { url };
             String[] signature = new String[] { "java.lang.String" };
             getJBossMBeanServer().invoke(objectName, "deploy", args, signature);
             } catch (Exception e) {
             throw new ServletException("couldn't deploy '" + url + "'");
             private MBeanServer getJBossMBeanServer() {
             for (Iterator i = MBeanServerFactory.findMBeanServer(null).iterator(); i.hasNext();) {
             MBeanServer server = (MBeanServer) i.next();
             if (server.getDefaultDomain().equals("jboss"))
             return server;
             throw new IllegalStateException("No 'jboss' MBeanServer found!");

            Deployment descriptor
            <?xml version="1.0"?>
            <!DOCTYPE web-app PUBLIC
             "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
             <display-name>jboss deployer</display-name>
             <description>jboss deployer</description>