2 Replies Latest reply on Nov 3, 2010 3:30 PM by wdfink

    Deploying WAR file via Ant on JBoss AS 6

    kwutzke

      Hello,

       

      I'm all new to JBoss AS. I read that JBoss AS is built on top of Tomcat in some way. I'm currently using Ant and I'd like to know whether the deploy and undeploy tasks

       

        <taskdef name="deploy"   classname="org.apache.catalina.ant.DeployTask" />
        <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" />
      
      

      tasks are available on JBoss AS as well to deploy WAR files.

       

      Maybe there are similar tasks?? Alternatives?

       

      Karsten

        • 1. Re: Deploying WAR file via Ant on JBoss AS 6
          peterj

          I haven't used those tasks but they will probably not work. Looking at the comments in the code (with are very little and leave a lot to the imagination) it would appear that the Tomcat management interfacei s used to facilitate the deploy, and that will not work with JBoss AS. Usually, I just use the copy task and copy the WAR file, or the exploded WAR directory to the server/xxx/deploy directory. If you used the exploded directory form, make sure to use the .war extension for hte directory name (Tomcat doesn't require that the directory have a .war extension, but JBoss AS does).

          • 2. Re: Deploying WAR file via Ant on JBoss AS 6
            wdfink

            I do this with the following ant targets:

             

             

            <!--  GENERAL TARGETS  in a global file to import --->

              <!-- used for deploy targets to qualify the applications lib and deploy directory -->

              <property name="jboss.application.dir" value="server/myApp"/>

              <property name="jboss.application.deploy.dir" value="${jboss.application.dir}/deploy"/>

              <property name="jboss.application.lib.dir" value="${jboss.application.dir}/lib"/>

              <property name="jboss.application.conf.dir" value="${jboss.application.dir}/conf"/>

             

            <!--  ===  check the JBoss environment for deploying targets  ===  -->
              <target name="jboss.environment">
                <condition property="jboss.home" value="${env.JBOSS_HOME}">
                  <isset property="env.JBOSS_HOME" />
                </condition>
                <fail unless="jboss.home">
                  'jboss.home' is not set. Set the 'jboss.home' property or create an
                  environmental variable called 'JBOSS_HOME' pointing to the top-level
                  JBoss installation directory.
                </fail>
                <available property="jboss.present" file="${jboss.home}/bin/run.jar" />
                <fail unless="jboss.present">
                  Property "jboss.home" or 'JBOSS_HOME' is set but it does not seem to
                  point to the right directory. The file "run.jar" must be available at
                  ${jboss.home}/bin.
                </fail>
              </target>

            <!--  ===  check the JBoss environment for deploying targets  ===  -->

              <target name="jboss.environment">

                <condition property="jboss.home" value="${env.JBOSS_HOME}">

                  <isset property="env.JBOSS_HOME" />

                </condition>

                <fail unless="jboss.home">

                  'jboss.home' is not set. Set the 'jboss.home' property or create an

                  environmental variable called 'JBOSS_HOME' pointing to the top-level

                  JBoss installation directory.

                </fail>

             

                <available property="jboss.present" file="${jboss.home}/bin/run.jar" />

                <fail unless="jboss.present">

                  Property "jboss.home" or 'JBOSS_HOME' is set but it does not seem to

                  point to the right directory. The file "run.jar" must be available at

                  ${jboss.home}/bin.

                </fail>

              </target>

             

            <!-- use and deploy -->

              <target name="deploy" depends="jboss.environment, package" description="Deploy the persistence to the JBOSS_HOME server">

                <copy file="${my.ear}" todir="${jboss.home}/${jboss.application.deploy.dir}"/>

                <copy file="${myLib.jar}" todir="${jboss.home}/${jboss.application.lib.dir}"/>

            <echo level="warning" message="==  It is recommended to restart JBoss if the libraries are changed  =="/>

            </target>