Monday, April 18, 2005

[itsdifferent] JBOSS - The New 'BOSS' of Java App Servers

The JBoss Application Server is an open-source EJB solution that deserves your attention. Why? Because not only does the JBoss server have some impressive features that Weblogic, WebSphere, and the other big players don't, but it also boasts about more than 150,000 downloads per month and more than 2,000 developers worldwide. This article has been adapted from the developer manuals and the aim is to offer a basic outlook to JBoss.

Installing JBoss
Before installing and running the server, you should check that your JDK installation is working. You will need the JDK binaries directory in your PATH (this is essential: see below) not just for the user account, which is doing the installation, but also for the user account that will run the server. If you are running the server as root, you should check that the JDK binaries are in the PATH even for the root (root and ordinary users normally have different PATH settings). You won't need to specify a CLASSPATH environment variable if you don't normally have to.

The next step will be to download, install and test the JBoss server. There is no requirement for root access to run JBoss as none of the default ports are below the 1024 privileged port range. You will need to define a JBOSS_DIST environment variable that points to the installation location of the JBoss installation directory. This is required to build and run all of the documentation examples you will download later.JBoss is distributed as a ZIP file. 

Installation of binary package
Download the binaries and place it in a temporary directory and use the JDK jar tool to decompress it to the place where you want JBoss installed. The top level JBoss directory of the unzipped binary will be referred to as the JBOSS_DIST directory.

Make sure, that this user has the JDK binaries in his command path and that he has write access to the JBoss directory (needed for log files and deployment). You are now ready to change to the bin directory, and run the JBoss server: (Code 1)

code 1:
  On Unix/Linux:
  cd JBOSS_DIST/bin
  On Win32:
  cd JBOSS_DIST\bin

A proper installation should start without any error messages or exceptions being thrown. It will produce several pages of output on startup. The console output should look something like the following at the start and end for JBoss-2.2.2 on Linux: (Code 2)

Code 2:
  bash-2.04$ /bin/sh
  jboss.home = /tmp/JBoss-2.2.2
  Using JAAS LoginConfig: file:/tmp/JBoss- 2.2.2/conf/default/auth.conf
  Using configuration "default"
  [Info] Java version: 1.3.1,Sun Microsystems Inc.
  [Info] Java VM: Java HotSpot(TM) Server VM 1.3.1-b24,Sun Microsystems Inc.
  [Info] System: Linux 2.2.16-22,i386
  [Shutdown] Shutdown hook added
  [Service Control] Registered with server
  [Service Control] Initializing 24 MBeans
  [Service Control] Started 24 services
  [Default] JBoss 2.2.2 Started in 0m:7s

Now that you have the JBoss server installed, set the JBOSS_DIST environment variable to the installation location.

Directory structure
The source code for all examples in the JBoss documentation is available as a single archive, which can be downloaded as or documentation-example.tar.gz from the documentation section on In the documentation section follow the link to the documentation files download. You should download the archive format of your choice and unpack the archive into an empty directory. This will create a directory structure like the one shown in Figure 1. 

You need Ant to compile and run the example presented in the JBoss documentation. Ant is the standard build tool used by most open source Java projects and is widely being used in commercial settings as well. You can download Ant from the following URL

Once you have the Ant distribution, unarchive it to create a jakarta-ant-1.4 directory. The Ant documentation is located in the docs/manual directory. You should start with the docs/manual/ index.html file and browse through its contents if you want to use Ant. You won't need to know anything about Ant build scripts in order to compile and run the examples in the JBoss documentation. All we care about at this point is that you have Ante installed and available in your exestuation path such that you can run ant from the command line. To do this you need the path to the jakarta-ant-1.4/bin directory in your PATH environment variable(or the equivalent construct for you OS). So for example, I have Ante installed in /usr/local/Java/Ant/ jakarta-ant-1.4 and my PATH contains /usr/local/Java/Ant/ jakarta-ant-1.4/bin. On a win32 platform with Ant installed in G:/tmp/jakarta-ant-1.4 you would need G:/tmp/jakarta-ant-1.4/bin in your PATH. Setup your PATH now.

Installing Ant
You need the bin directory of a 1.3 JDK (Java development kit) in your path as well for access to the java interpreter and java compiler. 
You also typically need to set the JAVA_HOME environment variable to point to the location of a JDK 1.3 installation so that Ant can find the javac compiler. Your Ant installation may have been configured such that this is not necessary and you can try the following installation test without this set at first. Test the Ant installation by opening a shell or command prompt. Next create a build.xml file in the current directory that contains the contents listed in the following (Code 3):

Code 3:
  Ant build.xml script for testing an Ant installation
  <!-- Simple Ant build script to test an Ant installation -->
  <project name="TestInstall" default="run" basedir=".">
     <target name="init">
        <available file="" property="ASimpleHelloObject"/>
  <target name="ASimpleHelloObject" unless="ASimpleHelloObject" depends="init">
     <echo file="">
  public class ASimpleHelloObject {
     public static void main(String[] args)
     { System.out.println("ASimpleHelloObject.main was called");
  } </echo>
     <echo message="Wrote" />
    <target name="compile" depends="ASimpleHelloObject">
        <javac destdir="." srcdir="." debug="on" classpath=".">
                   <include name=""/>
       <target name="run" depends="compile">
       <java classname="ASimpleHelloObject" classpath="." />
            <echo message="Ant appears to be successfully installed" />

On a linux system with the build.xml file in /tmp you should see output as shown in Code 4:

Code 4:
  bash-2.04$ antBuildfile: build.xml
       [echo] Wrote
       [javac] Compiling 1 source file to /tmp
  ASimpleHelloObject.main was called
      [echo] Ant appears to be successfully installed
  Total time: 2 seconds

On a win32 system with the build.xml file in D:/temp you should see output as shown in Code 5:

Code 5:
  Buildfile: build.xml
  compile: [javac] Compiling 1 source file to D:\temp
  ASimpleHelloObject.main was called
      [echo] Ant appears to be successfully installed
  Total time: 2 seconds

Instead if 'out' is used you'll see what is shown in Code 6: 

Code 6:
  Warning: JAVA_HOME environment variable is not set.
  If build fails because sun.* classes could not be found you will need to set the   
  JAVA_HOME environment variable to the installation directory of java.
  Buildfile: build.xml
      [echo] Wrote
      [javac] Modern compiler is not available - using classic compiler
      [javac] Compiling 1 source file to D:\temp
  D:\temp\build.xml:22: Cannot use classic compiler, as it is not available A common   
  solution is to set the environment variable JAVA_HOME to your jdk directory.
  Total time: 1 second

Then you need to setup the JAVA_HOME environment to point to your JDK 1.3 installation.

JavaBean implementation
In this step we will look at the code for a simple Enterprise JavaBean. The example, which is called 'Interest', is a simple stateless session EJB. Its job is to calculate the amount of compound interest payable on a sum of money borrowed over a specified term with a specified interest rate. 

In fact, there is only one functional line of code in the whole package.
As a reminder, and Enterprise JavaBean has a minimum of three classes, the remote interface, the home interface, and the bean implementation. The remote interface is the class that exposes the methods of the EJB to the outside world. In the example, the remote interface is the class The home interface specifies how to create a bean that implements the remote interface. In this example, is the home interface. The bean implementation provides an implementation of the methods specified by the remote and home interfaces. Here, InterestBean is the Bean class. Of course, a Bean can include other classes, or even other packages, but the classes listed above are the minimum. The classes must be packaged into a JAR archive with a directory structure that reflects the hierarchy of packages. 
In the example, the classes are in the package, so they need to be in the directory org/jboss/docs/interest/ and that is what you will find in the examples distribution. Before the jar archive with all the classes is created there must be a directory called META-INF to store the deployment descriptor (always called ejb-jar.xml) and - optionally - another XML file to tell the server about application specific server infomormation. With JBoss, this file must be called jboss.xml.

The jar file you created is then deployed on the JBoss server. On the client side you need a file that tells your client where to initially find the JNDI naming service. From this service the client will look up the Interest bean and get back the home interface of the bean. The home interface is used to get a remote interface of the bean. He can now use this remote interface to access the functions provided by the Enterprise Java Bean a.k.a EJB.

We need three classes: the remote interface, the home interface, and the bean implementation. Download the code for all these interfaces from this URL: Also read about the deployment descriptor and more. 

The JBoss App server is a full-featured, J2EE app server with robust EJB support. It is the most popular and robust open-source EJB solution, and is packed with some interesting features that are bringing-and should continue to bring-attention to the software.

Note: This Group is not a Job Searching Group, so please co-operate and dont transfer any kind of job related material across this Group.AnyOne doing so can be banned from the Group
Thanx , Group Co-Ordinators



job opportunitya said...

Incredible blog. I admired your site and I will be
back once again to view it! I use much of my spare
time searching for blogs like yours.
Please take a journey to my plastic surgery fort worth blog.

job opportunitya said...

Excellent blog. Your site was great and will be
finding it again!  I surf the net for blogs like
Check out my penis plastic surgery blog, please!