HOWTO run JBoss 3.0 examples

Copyright (c) 2001-2002   Dernière mise à jour (Last update):

Introduction

JBoss is an Open Source, standards-compliant, application server implemented in 100% Pure Java and distributed for free. I didn't want to buy the documentation, so I had to struggle a bit to have the JBoss.3.0TemplateAndExamples/template sample working. The procedure is 100% command line, using Ant. Comparing to the available document , there are several missing ingredients in the receipe. So this is a small HOWTO to tell the exact procedure to run the sample. While I was here, I also describe the CMP2 example.

Download the JBoss 3.0 samples from JBoss.org :
JBOSS 3.0 GETTING STARTED
JBoss Group, LLC

The JBoss Group members are writing a free "getting started" booklet that covers the 3.0 series. It is the basis for the future documentation book under development. This documentation is directly written by the authors of JBoss. If you quickly want to get started with JBoss this includes all the examples you need and a step by step approach.

Download Draft 3.

Download Template and Examples.


Prerequisites

Start server

$ cd $JBOSS_DIST/bin
$ ./run.sh &
... blabla ...
13:02:23,099 INFO  [Server] JBoss (MX MicroKernel) [3.0.2 Date:200208271339] Started in 1m:56s:675ms

Make and deploy "template" EJB and client

First I propose this script, useful in a lot of Java projects, that adds to CLASSPATH all jars found in given directory; call it makejavacp and put it in your PATH:
#!/bin/sh
# make Java CLASSPATH
echo We take all jars in $1
LOCAL_CLASSPATH=`echo $1/*.jar | tr ' ' ':'`
export CLASSPATH=$LOCAL_CLASSPATH:$CLASSPATH
echo CLASSPATH=$CLASSPATH
Now we can add the client JBoss libraries to the CLASSPATH:
cp $HOME/src/xdoclet/lib/xdoclet.jar $ANT_HOME/lib
source makejavacp $JBOSS_DIST/client
source makejavacp $ANT_HOME/lib
This is one of the missing ingredients in the receipe.
Edit .ant.properties to tell the build.xml where xdoclet is:
xdoclet.home=$HOME/src/xdoclet
Also set the jboss.home property. Now we can make and deploy the client:
$ cd $HOME/JBoss.3.0TemplateAndExamples/template
$ ant
... blabla ...
create-client:
     [echo] JBoss Home on Unix: /home/jmv/binaries/jboss-3.0.2
     [echo] Java Home on Unix: /usr/java/j2sdk1.4.0_01/jre
     [copy] Copying 1 file to /home/jmv/binaries/JBoss.3.0TemplateAndExamples/template/build/bin
     [copy] Copying 1 file to /home/jmv/binaries/JBoss.3.0TemplateAndExamples/template/build/bin
     [copy] Copying 1 file to /home/jmv/binaries/JBoss.3.0TemplateAndExamples/template/build/bin
     [copy] Copying 1 file to /home/jmv/binaries/JBoss.3.0TemplateAndExamples/template/build/bin

main:

BUILD SUCCESSFUL
In the server window we have many lines ending with :

13:19:57,403 INFO  [MainDeployer] Deployed package: file:/home/jmv/binaries/jboss-3.0.2/server/default/deploy/web-client.war

Run client

We first have to add the newly created classes to the CLASSPATH. This is one of the missing ingredients in the receipe.
$ export CLASSPATH=build/classes:$CLASSPATH
$ source build/bin/run-client.sh

The client response on standard output is this:
New Entity Id is: 3

Make and deploy "cmp2" EJB and client

This Container Managed Persistance exemple has 3 EJB classes : Gangster, Organization and Job. Let's set the working directory :
cd $HOME/JBoss.3.0TemplateAndExamples/cmp2
Here it is not necessary to adjust the CLASSPATH as before, since the build.xml does it. But we need a second form of the JBOSS variable -;( :

$ export JBOSS_HOME=$JBOSS_DIST

This generic ant command lists the Ant targets:
$ ant -verbose -projecthelp
 [property] Loading Environment env.
Main targets:

Subtargets:

 build-client.jar
 build-ejb.jar
 clean
 cleandist
 compile
 deploy
 prepare
 setup
 teardown
 test
 test-gui
 undeploy

Default target: deploy
So just typing ant will deploy (and before that compile) the exemple. During deployment, the server  creates successfully 4 database tables:
In the working directory the output directory gets populated. Unfortunately the dependancies between targets are not specified in build.xml , so we must do things one after another. The next command runs a small client that populates database tables, thus creating Mafia, Triads, Corleone, Robbery and the like (look at the messages on server side).
$ ant setup

Run "cmp2" client

Now we can start a GUI test client based on Junit, the Java testing framework.
$ ant test-gui
a GUI test client based on Junit


Copyright (c) 2001-2002 Jean-Marc Vanel. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation