Rapid Java class deployment on WebSphere

This entry is part of the Maximo Java Development series.

In this post I will describe how to minimize the time needed to redeploy the custom Java code in Maximo running on WebSphere during the development phase.

Note: The techniques explained in this article (except the first one) are recommended only for development environments.

Here are the four methods I know to perform this task (the last is the fastest).


Rebuild and redeploy (30 minutes)

The standard procedure of updating custom Java classes in WebSphere is VERY time consuming and consists of the following steps:
  1. Copy the custom Java classes under [SMPDIR]\maximo\applications\maximo folder.
  2. Rebuild Maximo EAR.
  3. Redeploy the EAR.

Use sync-websphere-maximo.cmd script (10 minutes)

There is a well hidden script named sync-websphere-maximo.cmd under [SMPDIR]\applications\maximo directory that takes the classes in the businessobjects, maximouiweb, mboweb, meaweb and lib directories and roughly copies them to the WAS MAXIMO.ear folder.
First of all you have to configure the script editing sync-websphere-maximo.xml file and set maximo.websphere.dir property.
  1. Copy the custom Java classes under [SMPDIR]\maximo\applications\maximo folder.
  2. Run the sync-websphere-maximo.cmd script.
  3. Restart Maximo application server.

Rapid approach (6 minutes)

A fast technique that I use is to directly copy java class files in the MAXIMO.ear directory under WebSphere tree. In a typical deployment it is located under [WSDIR]\AppServer\profiles\ctgAppSrv01\installedApps\ctgCell01\MAXIMO.ear.
The little trick is to use a good file archiver tool like 7-Zip to dynamically add/replace files in the businessobjects.jar file without having to extract and rebuild it.
This is the exact sequence to follow.
  1. Stop Maximo application server (do this before modifying businessobjects.jar file to avoid corrupting it).
  2. Copy the custom Java classes into MAXIMO.ear folder.
    1. If the class files belongs to maximouiweb module I just copy them in the maximouiweb.war\WEB-INF\classes directory.
    2. If the class files belongs to businessobjects module I open the businessobjects.jar file with 7-Zip (with a right click) and drag and drop the custom class files into the right folders.
  3. Start Maximo application server.

Super-fast approach (5 minutes)

The previous technique can be further improved with a little trick (thanks Diego for the tip).
First of all you have to force Websphere to load the unpacked businessobjects.jar:
  1. Stop Maximo application server.
  2. Go in MAXIMO.ear folder and unzip the businessobjects.jar file into a directory named businessobjects.jar.
  3. Rename the businessobjects.jar file (e.g. businessobjects.orig.jar)
  4. Start Maximo application server and check everything is ok.

After having performed this configuration you can copy your class files directly in the 'exploded EAR' with this procedure.
  1. Stop Maximo application server.
  2. Copy the custom Java classes into businessobjects.jar or maximouiweb.war subdirectories of MAXIMO.ear folder.
  3. Start Maximo application server.
Note that step 2 can be automated setting the Eclipse destination directory directly to businessobjects.jar directory (unchecking the 'scrub output dir' in the project options under Java - Compiler - Building). However this may worth a separate article...

Speed-of-light approach (seconds)

We can further improve the 'super-fast' approach leveraging the WebSphere automatic class reload (thanks to Bartosz).
  1. Stop Maximo application server.
  2. Go in MAXIMO.ear folder and unzip the businessobjects.jar file into a directory named businessobjects.jar.
  3. Rename the businessobjects.jar file (e.g. businessobjects.orig.jar)
  4. Change WebSphere configuration
    1.  Log into the WebSphere web console.
    2. GoTo "Enterprise Application" - MAXIMO - "Class loading and update detection".
    3. Set "Reload classes when application files are updated" checkbox and set "Pooling interval for updated files" to 5 seconds.
    4. Ensure "Debug Mode" is also enabled on MXServer application server.
  5. Start Maximo application server and check if everything is ok.

After these changes you can modify java classes and if you would like to refresh classes on WebSphere server you only need to copy the file into the businessobjects.jar or maximouiweb.war folder. WebSphere will automatically recognize new classes and will reload them so you don’t need to restart Maximo application.
If you are using Eclipse to develop the changes you can create simple ant builder which will responsible for copying updated files to businessobjects.jar and maximouiweb.war folders.

Labels: , , ,