I recently had some interest from a prospective employer who were looking for someone with JBoss and Tomcat experience. Having had extensive use of these systems in my previous role, I figured I would write a quick howto to get people up and running with JBoss in a short time period. Jboss AS (application server) is an open source Java Enterprise Edition (Java EE) based application server, similar to Goldfish. As it is Java based, it runs on multiple platforms and architectures. Jboss features clustering, fail over, load balancing, distributed deployment, deployment API, management API and much more so its a very versatile platform for serving up your applications.
True to form, this guide is written with linux o/s in mind. If you run windows, you should simply adapt the shell scripts into windows ‘.BAT’ format.
Getting started
Make yourself a new system user for security, then become that user:
$ sudo useradd -d /home/jboss -m jboss
$ sudo su - jboss
$ mkdir /home/jboss/dist
Grab JBoss from http://www.jboss.org/jbossas/downloads/. I use 5.1.0 but version 6 is now available. Also be wary when you download your copy of jboss, the download page has two copies of each version normally, one for Java 5 and one for Java 6. Stick the download into your /home/jboss/dist directory
Grab your preferred JDK http://java.sun.com/javase/downloads/. You could use your systems installed JDK (if you have one), but for the duration of this guide we will run with a fresh download. Stick the download in /home/jboss/dist directory
When finished, you end up with two files (jboss-5.1.0.GA.zip & jdk-*.bin) which you need to unpack and make necessary symlinks:
$ cd /home/jboss
$ unzip ./dist/jboss-5.1.0.GA.zip
$ chmod +x ./dist/jdk-6u18-linux-i586.bin
$ ./dist/jdk-6u18-linux-i586.bin
$ mkdir projectdata
$ mkdir projectdata/logs
That should have Jboss and Java installed, so time to set up our symlinks to make things easier (ensure to change the names here to match your JDK version and Jboss version)
$ ln -s ./jboss-5.1.0.GA jboss
$ ln -s ./jdk1.6.0_18 java
$ cd projectdata
Now time to set up the startup scripts and fire up Jboss! Paste the following in a file called startjboss.sh
#!/bin/bash
# set variant. Default is fine for most, but all is required for clustering
export VARIANT='default'
#export VARIANT='all'
#export VARIANT='minimal'
#export VARIANT='standard'
export PROJECT_HOME=/home/jboss/projectdata
export JAVA_HOME=/home/jboss/java
export JBOSS_HOME=/home/jboss/jboss
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PATH:$JBOSS_HOME/bin
#
# include any extra java opts here
#export JAVA_OPTS=$JAVA_OPTS:" "
# including any extra classpaths here
#export CLASSPATH=$CLASSPATH:" "
#
echo "******************************************"
echo "Jboss starting with the following options:"
echo "******************************************"
echo "Variant: $VARIANT"
echo "Home: $PROJECT_HOME"
echo "Java Home: $JAVA_HOME"
echo "Jboss Home: $JBOSS_HOME"
echo "Ant Home: $ANT_HOME"
echo "Options: $JAVA_OPTS"
echo "Additional classes: $CLASSPATH"
echo ""
echo "JAVA PROCESS WILL BACKGROUND AND A TAIL -F OF SYSTEM.LOG WILL COMMENCE"
echo "CTRL-C WILL EXIT SYSTEM.LOG BUT WILL NOT KILL THE BACKGROUNDED JAVA PROCESS"
echo ""
read -p "Press enter key to boot with these options..."
#
#erase jboss temp
echo Cleaning Jboss temp dir
rm -rf $JBOSS_HOME/$VARIANT/default/tmp/*
#
cd $JBOSS_HOME/bin
./run.sh -c $VARIANT > $PROJECT_HOME/logs/system.log 2>&1 &
tail -f $PROJECT_HOME/logs/system.log
and paste the following into a file called stopjboss.sh
#!/bin/bash
#
export PROJECT_HOME=/home/jboss/projectdata
export JAVA_HOME=/home/jboss/java
export JBOSS_HOME=/home/jboss/jboss
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PATH:$JBOSS_HOME/bin
echo "******************************************"
echo "Jboss shutting down"
echo "******************************************"
#
cd $JBOSS_HOME/bin
./shutdown.sh -S
tail -f $JBOSS_HOME/server/default/log/server.log
Then set those two files to be executable, then fire up jboss. The startjboss.sh script will background the jboss process and then begin tailing the STDOUT logs of jboss. You can find jboss server.log and boot.log in /home/jboss/jboss/server/VARIANT/log/ where VARIANT is the variant type defined at the top of the startjboss.sh script.
$ chmod +x startjboss.sh stopjboss.sh
$ ./startjboss.sh
Give it a couple of minutes to fully come up (it takes 1 minute, 2 seconds on my home machine while im doing other tasks) and then you can find the web screen open at http://127.0.0.1:8080. Be aware as jboss compiles things when they are being ran for the first time, your web screens make take a while (especially the admin portion of the web screen. The default username and password for the administration page is ‘admin’ for both.
To halt the Jboss server is just as easy
$ cd /home/jboss/projectdata
$ ./stopjboss.sh
As soon as you see this line, hit CTRL-C to exit the tail and thats jboss shutdown cleanly.
INFO [org.jboss.bootstrap.microcontainer.ServerImpl] (JBoss Shutdown Hook) Shutdown complete
Its worth doing a quick check to see if the java process also cleaned itself up correctly and issue a sig 9 to force kill it, if its still hanging round
ps auwx | grep java | grep jboss
Ill post more in the near future on how to create & deploy EAR (enterprise app), WAR (webapp) and JAR (EJB) files so you can get more out of the jboss app server, but for now, congratulations you just took the first step to getting your applications served by an excellent piece of technology.
Recent Comments