JON Bundle Deployer Tool runs in an infinite loop when calling another target with antcall

Solution Verified - Updated -

Environment

  • JBoss Operations Network (JON) 2.4.0
  • JBoss Operations Network Bundle Deployer Tool
  • Deploy.xml file containing:
    <?xml version="1.0"?>
    
    <project name="example.com-website" default="main" 
             xmlns:rhq="antlib:org.rhq.bundle">    
       <!-- Set global properties for this build -->
       <!--   <property environment="env"/>     -->
       <!--   <property file="install.properties"/> -->
    
       <rhq:bundle name="Call Ant Task" version="1.0" description="Call Ant Task">
            <rhq:deployment-unit name="JEE Application Guessv1" preinstallTarget="chk_platform" postinstallTarget="install_appservers" >
                <rhq:archive name="guessv1.zip">
                </rhq:archive>
            </rhq:deployment-unit>
     
        </rhq:bundle>
    
        <target name="main"/>
    
        <target name="chk_platform">
        <property name="preinstallTargetExecuted" value="true"/>
        <echo message="Doing preinstall task...." />
        </target>
        
      <target name="install_appservers">
      <property name="postinstallTargetExecuted" value="true"/>
      <echo message="Doing postintall task..."/>
      <antcall target="doSomethingElse">
          <param name="param1" value="value"/>
      </antcall>
    </target>
    
    <target name="doSomethingElse">
      <echo message="param1=${param1}"/>
    </target>
    </project>
    

Issue

  • I'm working with the JON Bundle Deployer Tool and attempting to use "antcall" within the deploy.xml for calling a target defined within the deploy.xml.
  • The bundle is deployed, but the Bundle Deployer Tool goes into an infinite loop.

Resolution

  • This has been logged as a bug: https://bugzilla.redhat.com/show_bug.cgi?id=676703.   The workaround is rather than use <antcall> to call a target within the same deploy.xml, use <ant> and put your custom targets in a separate build file.  For example:

  • In the deploy.xml, use this as part of the deployment-unit task:

<rhq:deployment-unit name="jar" postinstallTarget="useAntCall">
  • The "useAntCall" target looks like this within deploy.xml:
<target name="useAntCall">
  <ant antfile="another.xml" target="doSomething">
    <property name="param1" value="111"></property>
   </ant>
</target>
  • Now create a separate "another.xml" file - it sits next to the deploy.xml file (i.e. its in the same directory as deploy.xml). another.xml looks like:
<?xml version="1.0"?>
   <project name="another" default="main">
       <target name="doSomething">
          <echo>inside doSomething. param1=${param1}</echo>
   </target>
</project>

Root Cause

The problem is that <antcall> invokes the same build file (it seems to reprocess the tasks that appear outside of a <target> - and because JON has a customized <bundle> task, it gets re-invoked and does its thing (again) which ends up going in an infinite loop.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.