-
1. Re: ant task for deploying ?
mikefinn Feb 20, 2004 12:27 AM (in response to tom.baeyens)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:
http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss.management.local%3AJ2EEServer%3DLocal%2Cj2eeType%3DJ2EEApplication%2Cname%3Dfoo.ear
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 Feb 23, 2004 10:07 AM (in response to tom.baeyens)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 codepackage 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) { e.printStackTrace(); 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" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>jboss deployer</display-name> <description>jboss deployer</description> <servlet> <servlet-name>deployer</servlet-name> <servlet-class>org.jbpm.ejb.deploy.DeployServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>deployer</servlet-name> <url-pattern>/deploy</url-pattern> </servlet-mapping> </web-app>