Friday, March 07, 2008

An example JBoss build and deployment project

[Edit: also see the demo section of the ControlTier Wiki for an up to date version of this]

(It was when I posted these notes to our Google group that I realized that there's real value in being able to post HTML. With that in mind. I'm re-posting here complete with links and formatting!)

These notes document using the ControlTier Elements Solution Library to build and deploy Sun's "Duke's Bank" sample application (from their J2EE 1.4 Tutorial) to JBoss 4.0.3SP1 following the "Getting Started with JBoss 4.0" guide. I've tested the project on Windows 2003 Server R2 and CentOS 4.5 (and it can also be easily adapted to run on other Unix/Linux platforms). You'll need around 4GB of disk space and 1GB of memory on a reasonably up-to-date system.

The basic idea was to implement the instructions from chapter 4 as a Workbench project building and deploying the sample application to a development environment on the (single) node (localhost) that's also running Workbench and Jobcenter.

1) Install
  • Install the latest version of the Java 1.5 SDK available from Sun into "$CTIER_ROOT/pkgs" (for use both by ControlTier - instead of Java 1.4 - and the Dukes Bank application).
  • Create a new ControlTier project called "DukesBank" (JBoss 4.0 J2EE 1.4 "Duke's Bank" sample application project) using Workbench.
  • Download the Elements Solution Library 1.0 seed from Sourceforge and "Import" it using the Workbench administration page (note that you can also check out the library's source and use ProjectBuilder to build and load the library).
2) Configure
  • Configure a ProjectBuilder object and download from Sourceforge and load into Workbench either the Linux or Windows version of the objects as required (note that on Unix/Linux it is assumed installation will occur to "~/dukesbank", while on Windows to "C:\dukesbank") by cutting and pasting the appropriate commands:

    $ ad -p DukesBank -m Deployment -c Register -- -name elements -type ProjectBuilder -basedir $CTIER_ROOT/src/elements -installroot $CTIER_ROOT/target/elements -install
    .
    .
    .
    For more information about this object run: ad -p DukesBank -t ProjectBuilder -o elements -c Get-Properties -- -print
    [command.timer.Deployment.Register: 4.150 sec]

    $ ad -p DukesBank -t ProjectBuilder -o elements -c load-objects -- -format projectxml -filename $CTIER_ROOT/src/elements/demo/DukesBank/objects/linux.xml
    Loading "/home/demo/ctier/src/elements/demo/DukesBank/objects/linux.xml" ...
    1 file(s) have been successfully validated.
    Processing /home/demo/ctier/src/elements/demo/DukesBank/objects/linux.xml to /home/demo/ctier/antdepo/depots/DukesBank/deployments/ProjectBuilder/elements/var/null226801341.xml
    Loading stylesheet /home/demo/ctier/antdepo/depots/DukesBank/lib/ant/modules/ProjectBuilder/lib/load-objects/projectxml/project.xsl
    Mapping XML to properties ...
    Collecting object attributes ...
    Batching object attribute updates ...
    Batching resource and referrer updates ...
    Executing batch update ...
    [command.timer.load-objects: 20.873 sec]
    load-objects completed. execution time: 20.873 sec.

    C:\>ad -p DukesBank -m Deployment -c Register -- -name elements -type ProjectBuilder -basedir %CTIER_ROOT%\src\elements -installroot %CTIER_ROOT%\target\elements -install
    .
    .
    .
    [command.timer.Deployment.Register: 2.359 sec]

    C:\ctier\tmp>ad -p DukesBank -t ProjectBuilder -o elements -c load-objects -- -format projectxml -filename windows.xml
    Loading "C:\ctier\tmp/windows.xml" ...
    1 file(s) have been successfully validated.
    Processing C:\ctier\tmp\windows.xml to C:\ctier\antdepo\depots\DukesBank\deployments\ProjectBuilder\elements\var\null580203106.xml
    Loading stylesheet C:\ctier\antdepo\depots\DukesBank\lib\ant\modules\ProjectBuilder\lib\load-objects\projectxml\project.xsl
    Mapping XML to properties ...
    Collecting object attributes ...
    Batching object attribute updates ...
    Batching resource and referrer updates ...
    Executing batch update ...
    [command.timer.load-objects: 6.906 sec]
    load-objects completed. execution time: 6.906 sec.

  • Download the required third-party packages from the Internet and upload them to Workbench via their "PlatformZip" and "JBossZip" object pages: apache-ant-1.7.0-bin.zip, J2EE 1.4 Tutorial Update 7, jbossj2ee-src.zip (note that you must unpack the required Zip archive from the downloaded Zip), and jboss-4.0.3SP1.zip. (Note: Make sure that you set the DAV directory path to "/pkgs/DukesBank/zip/zips" to match the object XML when uploading the package files).
  • Install the objects:

    $ depot-setup -p DukesBank -a install
    "Install" command running for object: (AntBuilder) development
    "Install" command running for object: (ProjectBuilder) elements
    "Install" command running for object: (Updater) development
    "Install" command running for object: (Site) development
    "Install" command running for object: (JBossServer) development

    C:\>depot-setup -p DukesBank -a install
    "Install" command running for object: (AntBuilder) development
    "Install" command running for object: (ProjectBuilder) elements
    "Install" command running for object: (Updater) development
    "Install" command running for object: (Site) development
    "Install" command running for object: (JBossServer) development
  • Download the sample job definitions from Sourceforge and install them into Jobcenter using "Upload Job XML File ..." via the "Create a new Job ..." page.
3) Run
  • Deploy the packages that support building the application using Ant and deploy and start the empty JBoss server instance (you'll be able to pick up the JBoss server page at http://localhost:8180 since JBoss is configured to run on non-default ports to avoid colliding with Workbench):

    [jboss@development dukesbank]$ ad -p DukesBank -t Updater -o development -c Deploy -- -resourcetype 'AntBuilder|Site'
    Start: "Run the coordinated deployment cycle across the configured Sites." commands: dispatchCmd
    begin workflow command (1/1) -> "dispatchCmd -command Deploy -resourcename .* -resourcetype AntBuilder|Site" ...
    dispatching command: "Deploy " to: (AntBuilder) development, (Site) development ...
    .
    .
    .
    dispatched command: Deploy completed for: (AntBuilder) development, (Site) development
    end workflow command (1/1) -> "dispatchCmd -command Deploy -resourcename .* -resourcetype AntBuilder|Site"
    [command.timer: 29.828 sec]
    Completed: execution time: 29.828 sec

    C:\>ad -p DukesBank -t Updater -o development -c Deploy -- -resourcetype "AntBuilder|Site"
    Start: "Run the coordinated deployment cycle across the configured Sites." commands: dispatchCmd
    begin workflow command (1/1) -> "dispatchCmd -command Deploy -resourcename .* -resourcetype AntBuilder|Site" ...
    dispatching command: "Deploy " to: (Site) development, (AntBuilder) development ...
    .
    .
    .
    dispatched command: Deploy completed for: (Site) development, (AntBuilder) development
    end workflow command (1/1) -> "dispatchCmd -command Deploy -resourcename .* -resourcetype AntBuilder|Site"
    [command.timer: 41.531 sec]
    Completed: execution time: 41.531 sec

    (Note that this command can also be run from Jobcenter using the "development.Deploy" job and setting the "resourcetype" to "AntBuilder|Site" from the "Choose Options and Run Job ..." page).
  • Edit the client JNDI properties file in the J2EE Tutorial source to adjust the hard-coded naming provider port (this is necessary since JBoss is deployed using non-default ports to avoid colliding with Workbench):

    $ pwd
    .../dukesbank/j2eetutorial14/examples/bank/dd/client
    $ diff jndi.properties jndi.properties.orig
    3c3
    < url="jnp://localhost:1199"> java.naming.provider.url=jnp://localhost:1099
  • Run the application build and deployment cycle to build the Duke's Bank application from source, initialize the database schema and deploy to JBoss:

    $ ad -p DukesBank -t Updater -o development -c BuildAndDeploy -- -buildstamp 20080222.0
    Start: "Run the coordinated end-to-end the build and deployment processes across the configured Builders and Sites.." commands: Build,Change-Dependencies,Deploy ...
    begin workflow command (1/3) -> "Build -buildstamp 20080222.0" ...
    Start: "Run the coordinated build cycle across the configured Builders." Beginning build process with the following builders: (AntBuilder) development ...
    workflow command (1/1) -> "dispatchCmd -buildstamp 20080222.0 -command Build -resourcetype [^\.]*Builder -dispatchOptions buildstamp" ...
    .
    .
    .
    Completed: execution time: 31.322 sec
    end workflow command (3/3) -> "Deploy -buildstamp 20080222.0"
    [command.timer.DukesBank.Updater.development.BuildAndDeploy: 2:14.950 sec]
    Completed: End-to-end build and update process completed: Build,Change-Dependencies,Deploy. execution time: 2:14.950 sec

    C:\>ad -p DukesBank -t Updater -o development -c BuildAndDeploy -- -buildstamp 20080222.0
    Start: "Run the coordinated end-to-end the build and deployment processes across the configured Builders and Sites.." commands: Build,Change-Dependencies,Deploy ...
    begin workflow command (1/3) -> "Build -buildstamp 20080222.0" ...
    Start: "Run the coordinated build cycle across the configured Builders." Beginning build process with the following builders: (AntBuilder) development ...
    workflow command (1/1) -> "dispatchCmd -buildstamp 20080222.0 -command Build -resourcetype [^\.]*Builder -dispatchOptions buildstamp" ...
    .
    .
    .
    Completed: execution time: 11.313 sec
    end workflow command (3/3) -> "Deploy -buildstamp 20080222.0"
    [command.timer.DukesBank.Updater.development.BuildAndDeploy: 2:06.844 sec]
    Completed: End-to-end build and update process completed: Build,Change-Dependencies,Deploy. execution time: 2:06.844 sec

    (Note that this command can also be run from Jobcenter using the "development.BuildAndDeploy" job and setting the "buildstamp" from the "Choose Options and Run Job ..." page).
If you don't want to go through this setup process, I've prepared a CentOS 4.5 VMware virtual machine with the demonstration installed and ready to roll that I plan to post to Sourceforge imminently. I'll also post the DukesBank project archive file if you'd like to avoid the type/object model setup steps and cut right to the chase finishing up configuration and running the demonstration.

Thanks,

Anthony.

5 comments:

Anonymous said...

I found this site using [url=http://google.com]google.com[/url] And i want to thank you for your work. You have done really very good site. Great work, great site! Thank you!

Sorry for offtopic

Anonymous said...

Can anyone recommend the well-priced Remote Management & Monitoring system for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: [url=http://www.n-able.com] N-able N-central it outsourcing
[/url] ? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!

daouda said...

Hi,
I'm a beguinner in controlier and zenoss.
I just want to know how i can connect controltier
and zenos so that controltier can be aware if zenoss sends its alerts.
Thanks

daouda said...

Hi again,
I also, how controltier can send command to zenoss?

Damon Edwards said...

Hi Daouda,

The best place to get help with ControlTier is the the ControlTier Google Group:
http://groups.google.com/group/controltier