3 Replies Latest reply on Sep 19, 2002 6:27 AM by nexux

    Developing w/ Ant, JSP, JBoss

    wpfeiffe

      I am running JBoss 2.4.4 with Tomcat 4.0.1, and am using Ant 1.4 to build/deploy an ear application to JBoss. My question is, during development, how can I get ant to deploy copy JSP files while I am working on the presentation portion without deploying the entire ear file. My problem is that the deploy directory of the war is not fixed, therefore I don't have a directory to do an ANT copy to.

      Any ideas?

      TIA,

      Bill Pfeiffer

        • 1. Re: Developing w/ Ant, JSP, JBoss

          Hi,

          I think I posted something like this in the security section recently: I've never found a decent solution other than setting up an external instance of Tomcat 4 on a different port, with a web-app context set up which points to your development area. This isn't too inconvenient as long as you don't have to setup security as well.

          Re-deploying the whole app while you're working on the presentation layer isn't very satisfactory in any case, as you loose the session state of the current user. If you're only modifying jsps, tomcat recompiles, you reload and only the layout will change.

          If you come up with a better solution let me know :).

          Luke.

          • 2. Re: Developing w/ Ant, JSP, JBoss
            wpfeiffe

            Is there a way to query JBoss, via code, as to where a given war application has been deployed to? Perhaps an Ant task can be written to do this.

            • 3. Re: Developing w/ Ant, JSP, JBoss
              nexux

              Hi,
              One way to copy your JSPs (or any other presentation files like images) when working with jboss (tested with version 2.4.6) is to proceed as follows:

              You will need:
              - Ant 1.5
              - bsf.jar (http://www-124.ibm.com/developerworks/projects/bsf)
              -js.jar (http://www.mozilla.org/rhino/)


              bsf.jar and js.jar must be in your ant classpath.

              Add a target and use the following javascript in your ant build.xml to just copy the jsps to the deployed directory. You can easily guess how it works and add more enhanced functionality to your ant build scripts.

              In this script, I am copying .jsp and .inc files as found in the includes.

              The ant script below is self explanatory. It just contains a lot of properties which contains the actual values for the directories and so on.

              Hope it helps:





              <![CDATA[
              jbosshome = StandardBuild.getProperty("jboss2.jboss.home");
              projectearfile = StandardBuild.getProperty("ear-war.jar.filename");
              oDir = new java.io.File(jbosshome + "/tmp/deploy/Default/" + projectearfile);
              oDirs = oDir.list();
              for (i=0; i < oDirs.length; i++)
              {
              if (oDirs.startsWith("web"))
              oWebDir = oDirs
              ;
              }
              oCopyDir = new java.io.File(jbosshome + "/tmp/deploy/Default/" + projectearfile + "/" + oWebDir + "/jsp");
              oMsg = StandardBuild.createTask("echo");
              oMsg.setMessage("Copying to : " + oCopyDir.toString());
              oMsg.execute();

              oFileset = copyjspFileset.clone();
              copyjsp1 = StandardBuild.createTask("copy");
              copyjsp1.setVerbose(true);
              copyjsp1.setOverwrite(true);
              copyjsp1.addFileset(oFileset);
              copyjsp1.setTodir(oCopyDir);
              copyjsp1.execute();
              ]]>