0

Background

Here's the set up:

  • Multi-developer environment using Subversion
  • NetBeans 8.0.2
  • JDK 1.7
  • Java EE6
  • JBoss 6.2 EAP running standalone

We may not change the tools; we may use neither Maven nor JRebel. Hardware upgrades are also not in scope.

Code Organisation

The source code, including web-related files, are checked out into:

C:\Apps\07-Work\Project\Project-Admin\Project-Admin-User-war\

This directory includes a common development structure (bold are checked out from the repository):

  • build - compiled files
  • dist - .war file
  • nbproject - project files
  • src - Java source code
  • web - JSF pages, WEB-INF directory, CSS files, etc.
  • build.xml - Ant script

JBoss Installation

The web application server is installed into:

C:\Apps\04-Tools\jboss-eap-6.2

Problem

The develop - deploy - test cycle is painfully slow. It can take upwards of 30 seconds to test a single change to a web page. Here's the current flow:

  1. Edit file in NetBeans.
  2. Save file.
  3. Shift+F11 (Run >> Clean and Build).
  4. Switch to browser tab (http://localhost:9990/console/App.html#deployments).
  5. Click Replace.
  6. Click Choose File.
  7. Select Project-Admin-User-war.war file.
  8. Click Open.
  9. Click Next.
  10. Click Save.
  11. Switch to browser tab (http://localhost:8080/admin/users/).
  12. F5 to reload the page.

The build (step 3) takes about 26 seconds; manual deployment adds to that.

Here's the ideal development cycle:

  1. Change a JSF page in NetBeans (note: this is a file checked out from repository).
  2. Save the JSF page.
  3. Alt+Tab to a browser window.
  4. F5 to reload the page.

It isn't as important to have hot deploy on Java source changes, as code development time tends to take much longer than simple web page layout changes.

Editing the exploded contents would mean developers are no longer editing files checked out from the repository and would therefore incur additional steps, or scripts, or possible loss of work.

Others have suggested the Deploy on save feature, which is disabled:

Run Project Properties

Another suggestion (as per the screen shot) is to run the application in debug mode, but selecting Debug >> Project (Ctrl+F5) didn't show page updates after changes.

Question

Is hot deploy of JSF pages possible using the given tools and constraints? If so, what are the exact steps required to achieve the ideal development cycle?

Standalone Configuration

The README.txt file shows that it is possible to "live deploy" content:

H) Manual mode only: Live replace portions of currently deployed unzipped content without redeploying:

cp -r target/example.war/foo.html $AS/standalone/deployments/example.war

Where the cp command on Windows translates to:

xcopy /e /s /y src dest

This leads to:

  1. Open a command prompt.
  2. Change directory: cd C:\Apps\04-Tools\jboss-eap-6.2\standalone\deployments
  3. Create skipdeploy to prevent deployment while copying is in progress: type nul >> Project-Admin-User-war.war.skipdeploy
  4. Copy files to create a directory containing the files that have changed: xcopy /i /y /e /s C:\Apps\07-Work\Project\Project-Admin\Project-Admin-User-war\web Project-Admin-User-war.war

Next:

  1. Delete skipdeploy: rm Project-Admin-User-war.war.skipdeploy
  2. Create dodeploy: type nul >> Project-Admin-User-war.war.dodeploy
  3. Return to the browser.
  4. Press F5 to refresh.

The result is that a resource bundle has gone missing:

Missing Resource Bundle

Related

Community
  • 1
  • 1
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
  • Would you accept `buy the fastest development computers available` as an answer? – mjn Jun 15 '16 at 16:39
  • Why is step 3 needed? Does't save automatically copy it? even in non-debug mode? did you check? Did you configure your jsf app to run in development mode? – Kukeltje Jun 15 '16 at 18:11
  • @Kukeltje: Save won't automatically copy it -- NetBeans doesn't know where JBoss keeps its WAR files, nor does NetBeans know whether JBoss is automatically exploding WAR files. NetBeans can be configured (as mjn's answer) to automatically deploy to JBoss, but that is only a partial solution. The solution that should take the shortest time is a straight copy to update the WAR file without either a rebuild or a redeploy. Whether the copy happens directly or indirectly (through the `deployments` directory) is now the crux of cracking this problem. – Dave Jarvis Jun 15 '16 at 21:00

2 Answers2

1

Here is a description of a Ant script change from 2009 found on http://wiki.netbeans.org. Maybe it is useful still.

http://wiki.netbeans.org/TaT_DeployOnBuildUsingJBoss

And another script solution:

How to setup JBoss server with Netbeans?

Community
  • 1
  • 1
mjn
  • 36,362
  • 28
  • 176
  • 378
  • 1
    @DaveJarvis well, within the given constraints (`We may not change the tools; we may use neither Maven nor JRebel`) I would say this is the best I could do (and even free). I will come back if I need a job ;) – mjn Jun 15 '16 at 17:30
0

Overview

Achieving hot deploy using JBoss 6.2 EAP running in standalone mode is accomplished in three parts: configuration, exploding, and hot deployment.

Configuration

Ensure that a deployment scanner is configured as shown:

Deployment Scanner Settings

Ensure the web subsystem and system properties are configured:

  1. Stop JBoss.
  2. Edit %JBOSS_HOME%\standalone\configuration\standalone.xml.
  3. Immediately after </extensions> (before <management>), disable caching:

    <system-properties>
      <property name="java.net.preferIPv4Stack" value="true"/>
      <property name="org.jboss.as.web.deployment.DELETE_WORK_DIR_ONCONTEXTDESTROY" value="true"/>
    </system-properties>
    
  4. Find the web subsystem (e.g., xmlns="urn:jboss:domain:web...).
  5. Append the following element:

    <configuration>
        <jsp-configuration development="true"/>
    </configuration>
    
  6. Save the file.
  7. Start JBoss.

Exploding

Exploding requires extracting the full contents of a WAR file with contents that will be deployed in the (very near) future.

  1. Clean and build the application (Shift+F11 in NetBeans).
  2. Change to the JBoss standalone deployments directory.
  3. Create a skip deploy file.
  4. Create the WAR directory.
  5. Extract the WAR file.
  6. Delete the skip deploy file.
  7. Create the do deploy file.

This resembles the following (on Windows platforms; substitute paths for %JBOSS_HOME% and %PROJECT_HOME% as required):

cd %JBOSS_HOME%\standalone\deployments
type nul >> Project-Admin-User-war.war.skipdeploy
mkdir Project-Admin-User-war.war
cd Project-Admin-User-war.war
jar -xvf %PROJECT_HOME%\dist\Project-Admin-User-war.war
cd ..
del *skipdeploy
type nul >> Project-Admin-User-war.war.dodeploy

Hot Deployment

Create a batch file that contains the following:

cd %JBOSS_HOME%\standalone\deployments
type nul >> Project-Admin-User-war.war.skipdeploy
xcopy /i /y /e /s %PROJECT_HOME%\web Project-Admin-User-war.war
del *skipdeploy
type nul >> Project-Admin-User-war.war.dodeploy

Web Development

The ideal development cycle has almost been achieved:

  1. Edit file in NetBeans.
  2. Save file.
  3. Run batch file.
  4. Alt+Tab to browser.
  5. F5 to refresh.

Ant has an OnSaveTask that can likely be coerced to run the batch, or even substitute for the batch file completely. Left as an exercise for the reader.

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315