Posted by & filed under Linux, Software.

  • DZone
  • Reddit
  • HackerNews
  • Twitter
  • Facebook
  • Google Plus
  • Pinterest
  • StumbleUpon
  • LinkedIn
  • Tumblr
  • BlinkList
  • Mister Wong
  • Add to favorites
  • Email

This short tutorial describes how to configure JBoss Application Server (Jboss GA 5.1.0) on a debian linux (Debian GNU/Linux 5.x “Lenny” ). Article starts with installation of java JDK and continues with JBoss installation and basic configuration according to standard  file system hierarchy. Also init.d. scripts configuration is given here.

Installing Java SDK

Nowadays  installing Java environment on Debian is an easy task. I used JDK 1.6. Don’t confound JDK with JRE, because bare Java Runtime Environment is not enough for running JBoss. Debian Wiki maintains (hope) a list of available java .deb packages, which are easily can be installed with your preferred way. I prefer aptitude, but apt-get of course works too.

$ aptitude install sun-java6-jdk
#or by good old apt-get.
$ apt-get install sun-java6-jdk

Installation is done after seconds. Now test your java installation with

$ java -version
# Here example result on my configuration:

java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) 64-Bit Server VM (build 11.2-b01, mixed mode)

If you get something like this, you’re done and your java should be already in the PATH.

Installing JBoss AS

Now let’s install  JBoss Application Server.

Preparing

Normally you are not willing  to start services (especially when they are accessed from outher machines) with root privileges. Therefore we have to define new user and group which will be used to manage JBoss.  So next line will create new group and new user with this group.

 $ groupadd jboss
 $ useradd -s /bin/bash -d /home/jboss -m -g jboss jboss

This jboss user has no password, so nobody can login with this username. If you consider to  login with jboss user,  password has to be set. Use passwd jboss command for that.

Download, Installation,  filesystem layout

Now  download desired Jboss version. I started with JBoss 5.1.0 GA, which can be download with:

$ cd /tmp # swithch to temp dir
$ wget http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/jboss-5.1.0.GA.zip/download

Check also the whole list of verisons if interested. As you may noticed JBoss binaries are packaged with ZIP. So it is comfortable to use unzip tool. Maybe you have to install it first.

But before you extract  downloaded file, we have to decide, where exactly should JBoss files be placed on a  file-system. Unfortunately JBoss is not quite conform to Linux File System Hierarchy Standard per default, so there are many possibilities for a location configuration. Some of you may want to place JBoss  into /opt directory. But I prefer to split the installation a little bit and  want to start by putting  JBoss core files in /usr/local/, where local, unchangeable and read-only files usually placed. E.g. I use  /usr/local/jboss/510 as JBoss 5.1.0 GA root.  So let’s create that location and extract files into it.

mkdir /usr/local/jboss #create new jboss directroy
chown jboss:jboss /usr/local/jboss #now its belongs touser jboss and group jboss
su jboss
mkdir /usr/local/jboss/510
cd /usr/local/jboss/510
unzip /tmp/jboss-5.1.0.GA.zip

At this moment you should have new working JBoss. If you want, test it with

bin/run.sh -b 0.0.0.0

Where -b 0.0.0.0 means that JBoss is listening for every ip address of current machine.

However at this stage the installed Jboss still brakes the  Linux Filesystem Hierarchy Standard, so let’s improve this situation.

After the first start of the server used configuration will have new directories /tmp and /work . The /tmp directory contain the temporarily state of the deployed applications and /work is contains compiled jsp pages of deployed applications. Therefore both directories are of temporal character and  should be on more appropriate place according to Linux standards.

I use only a default JBoss configuration,  which is defined under <jboss_root>/server/default, so I need to do further changes only for this configuration. My decision is to put both directories to /var /tmp/jboss.:

$ mkdir /var/tmp/jboss
$ chown jboss:jboss /var/tmp/jboss/
$ su jboss
$ mkdir /var/tmp/jboss/510
$ mkdir /var/tmp/jboss/510/tmp # creating alternavtive location for tmp
$ mkdir /var/tmp/jboss/510/work # creating alternavtive location for work
$ cd /usr/local/jboss/510/server/default # switch to configuration directory if not allready here.
$ rm -R tmp # delete existing tmp directory (server should not run at this moment)
$ rm -R work # delete existing work directory
$ ln -s /var/tmp/jboss/510/tmp ./tmp # Finaly create symbolic link to new place$
$ ln -s /var/tmp/jboss/510/work ./work # Finaly create symbolic link to new place

repeat the same for /log directory. It is common to have logs at one place in /var/log
create a log directory tree e.g. /var/log/jboss/510/ and let log link to it as was shown for tmp and work directories.

After that your configuration directory should look like:

$ ls -l /usr/local/jboss/510/server/default
drwxr-xr-x  6 jboss jboss 4096 22. Mai 2009  conf
drwxr-xr-x  6 jboss jboss 4096 23. Jan 00:10 data
drwxr-xr-x 15 jboss jboss 4096 22. Mai 2009  deploy
drwxr-xr-x 12 jboss jboss 4096 22. Mai 2009  deployers
drwxr-xr-x  2 jboss jboss 4096 22. Mai 2009  lib
lrwxrwxrwx  1 jboss jboss   19 23. Jan 01:07 log -> /var/log/jboss/510/
lrwxrwxrwx  1 jboss jboss   23 23. Jan 01:13 tmp -> /var/tmp/jboss/510/tmp/
lrwxrwxrwx  1 jboss jboss   24 23. Jan 01:13 work -> /var/tmp/jboss/510/work/

And your logs are of course accessible directly at new location e.g.

tail -1000f /var/log/jboss/510/server.log

Furthermore you should deploy your applications to /srv/jboss/510 to enable this location for automatically scan and deployment,just create a link from /default/deploy/. Call it e.g. applications.:

$ ln -s /srv/jboss/510 ./usr/local/jboss/510/server/default/deploy/applications #

So applications which are placed to /srv/jboss/510 will be automatically deployed on the server.

Start JBoss on boot

First of all you need a life-cycle management script used by init. Jboss already provides some of then.  Let’s use one of Red Hat default script by adopting it a little bit. First of all copy the script to common place (feel free to ad version ti scriptname if you need or like)

$ cp /usr/local/jboss/bin/jboss_init_redhat.sh /etc/init.d/jboss

If you want to access you fresh JBoss also from other IP addresses you need to change
JBOSS_HOST line according to:

JBOSS_BIND_ADDR=${JBOSS_HOST:-"-b 0.0.0.0"}.

0.0.0.0. binds it on all IP addresses. Consider to change also other param this file to mach your personal needs. Now you can automatically create all the symbolic links used by init service.


$ update-rc.d jboss defaults

Now your Jboss will start automatically after reboot…

Additional configuration

  • <jboss_root>/bin/run.conf file configures the start parameters of the server. Maybe default limits are not suitable for your applications. So check it.
  • Under <jboss_root>/server/default/conf you will find some configuration files of the default server configuration. One of the interesting is of course jboss-lo4j.xml, where you can precisely define logging processing.

Questions & Suggestions

Thank you for reading this. Please feel free to provide any suggestions to the topic of JBoss installation on Linux and specially on Debian. Of course your questions are welcome too!

  • http://alexander.holbreich.org/ shuron

    Alternative here is an JBoss 5 package:
    http://wiki.debian.org/JBossPackaging
    which is unstable and not official. I didn’t tried it. Someone of you?

  • Pingback: Kresnadi T. Budisantoso» Blogarchiv » Anleitung zur Installation eines JBoss AS 5.1.0 GA auf Debian 5

  • Jordi

    Thanks man, you save me!!
    I love to see that there’re good people around.

    Gratz!!

  • Willy Devil

    Great job Alexander! That guide was very useful to end my configuration!

    Thanks!

  • http://alexander.holbreich.org/ shuron

    You are wellcome. Next time I tell you how to instal JIRA on debian as standalone tomcat.

  • http://jobaptitudetest.blogsavy.com/ jackiejobtester

    Alex this guide was very helpful to my config. Thankx.

  • Sharron Clemons

    Thanks man, you save me!! I love to see that there’re good people around. Gratz!!

  • Pingback: links for 2011-05-24 « My place

  • mjl

    Its’ useful, but after reboot it will not start and even /etc/init.d/jboss is saying the same:

    JBOSS_CMD_START = cd /usr/local/jboss/bin; /usr/local/jboss/bin/run.sh -c default -b 0.0.0.0

    Maybe the problem is there, it is missing something:

    update-rc.d: warning: /etc/init.d/jboss missing LSB information
    update-rc.d: see
    Adding system startup for /etc/init.d/jboss …
    /etc/rc0.d/K20jboss -> ../init.d/jboss
    /etc/rc1.d/K20jboss -> ../init.d/jboss
    /etc/rc6.d/K20jboss -> ../init.d/jboss
    /etc/rc2.d/S20jboss -> ../init.d/jboss
    /etc/rc3.d/S20jboss -> ../init.d/jboss
    /etc/rc4.d/S20jboss -> ../init.d/jboss
    /etc/rc5.d/S20jboss -> ../init.d/jboss

    My server is debian 6.0

  • http://alexander.holbreich.org/ shuron

    I didn’t tried it with Debian 6. So can only guess.

    If i understood you correct, your update-rc.d script refused job for some reason. And now Jboss does not star automatically after machine restart?

    Try to run /etc/init.d/jboss script directly if it works, than you have only a small problem.
    RC scripts can be created manually very quick. :)

  • mjl

    Even run it directly, the same error message comes up. After it I put the so calles missing LSB information. No change :S

  • http://alexander.holbreich.org/ shuron

    Hmm…
    May be someone can help you if you post the whole error message here.
    Also it would be helpful to see your /etc/init.d/jboss script.
    Maybe it needs some more tunning on deb 6. I didn’t tried.

  • mjl

    /etc/init.d/jboss (based as here on redhat script)

    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: jbiss
    # Required-Start: $remote_fs
    # Required-Stop: $remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Example initscript
    # Description: This file should be used to construct scripts to be
    # placed in /etc/init.d.
    ### END INIT INFO
    #
    # $Id: jboss_init_redhat.sh 81068 2008-11-14 15:14:35Z dimitris@jboss.org $
    #
    # JBoss Control Script
    #
    # To use this script run it as root – it will switch to the specified user
    #
    # Here is a little (and extremely primitive) startup/shutdown script
    # for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,
    # it’s run by user ‘jboss’ and JDK binaries are in /usr/local/jdk/bin.
    # All this can be changed in the script itself.
    #
    # Either modify this script for your requirements or just ensure that
    # the following variables are set correctly before calling the script.

    #define where jboss is – this is the directory containing directories log, bin, conf etc
    JBOSS_HOME=${JBOSS_HOME:-”/home/jboss/jboss”}

    #define the user under which jboss will run, or use ‘RUNASIS’ to run as the current user
    JBOSS_USER=${JBOSS_USER:-”jboss”}

    #make sure java is in your path
    JAVAPTH=${JAVAPTH:-”/usr/lib/jvm/java-6-sun”}

    #configuration to use, usually one of ‘minimal’, ‘default’, ‘all’
    JBOSS_CONF=${JBOSS_CONF:-”default”}

    #if JBOSS_HOST specified, use -b to bind jboss services to that address
    JBOSS_BIND_ADDR=${JBOSS_HOST:+”-b $JBOSS_HOST”}

    #define the classpath for the shutdown class
    JBOSSCP=${JBOSSCP:-”$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar”}

    #define the script to use to start jboss
    JBOSSSH=${JBOSSSH:-”$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR”}

    if [ "$JBOSS_USER" = "RUNASIS" ]; then
    SUBIT=”"
    else
    SUBIT=”su – $JBOSS_USER -c ”
    fi

    if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
    # ensure the file exists
    touch $JBOSS_CONSOLE
    if [ ! -z "$SUBIT" ]; then
    chown $JBOSS_USER $JBOSS_CONSOLE
    fi
    fi

    if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
    echo “WARNING: location for saving console log invalid: $JBOSS_CONSOLE”
    echo “WARNING: ignoring it and using /dev/null”
    JBOSS_CONSOLE=”/dev/null”
    fi

    #define what will be done with the console log
    JBOSS_CONSOLE=${JBOSS_CONSOLE:-”/dev/null”}

    JBOSS_CMD_START=”cd $JBOSS_HOME/bin; $JBOSSSH”
    JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-”java -classpath $JBOSSCP org.jboss.Shutdown –shutdown”}

    if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
    export PATH=$PATH:$JAVAPTH
    fi

    if [ ! -d "$JBOSS_HOME" ]; then
    echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
    exit 1
    fi

    echo JBOSS_CMD_START = $JBOSS_CMD_START

    case “$1″ in
    start)
    cd $JBOSS_HOME/bin
    if [ -z "$SUBIT" ]; then
    eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &
    else
    $SUBIT “$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &”
    fi
    ;;
    stop)
    if [ -z "$SUBIT" ]; then
    $JBOSS_CMD_STOP
    else
    $SUBIT “$JBOSS_CMD_STOP”
    fi
    ;;
    restart)
    $0 stop
    $0 start
    ;;
    *)
    echo “usage: $0 (start|stop|restart|help)”
    esac

    updateing:

    update-rc.d jboss defaults
    update-rc.d: warning: /etc/init.d/jboss missing LSB information
    update-rc.d: see
    Adding system startup for /etc/init.d/jboss …
    /etc/rc0.d/K20jboss -> ../init.d/jboss
    /etc/rc1.d/K20jboss -> ../init.d/jboss
    /etc/rc6.d/K20jboss -> ../init.d/jboss
    /etc/rc2.d/S20jboss -> ../init.d/jboss
    /etc/rc3.d/S20jboss -> ../init.d/jboss
    /etc/rc4.d/S20jboss -> ../init.d/jboss
    /etc/rc5.d/S20jboss -> ../init.d/jboss

    even seen above, what Debian needs at the top of the scipt, this LSB something information … :S

    and when trying it manually start
    # /etc/init.d/jboss start
    bash: /etc/init.d/jboss: /bin/sh^M: bad interpreter: Nincs ilyen fájl vagy könyvtár

    after system reboot jboss not starting, during the boot it has some problem with /etc/init.d//rc: /etc/rc2.d/S20jboss: /bin/sh^M: bad interpreter: No such file or directory
    i give up here

  • http://alexander.holbreich.org/ shuron

    The problem that i see in your description is this:
    “bash: /etc/init.d/jboss: /bin/sh^M: bad interpreter:”
    Your sh schell interpreter is not found in /bin/sh
    may be it ist on other place or it is not installed at all.

    Try to find it with:
    which sh
    This shpoul return the lecation, normally:
    /bin/sh

    But somehow it’s imposble at all, im not so experienced at this.

  • mjl

    I tried it with ubuntu, the same. The proble is sure the “/etc/init.d/jboss missing LSB information”, but when i put it in the jboss init script, it helps not. :(( :SS :///

  • http://alexander.holbreich.org/ shuron

    Ah ok, seems to be an easy task.
    Ubuntu is based on debian, so don’t wounder.

    Let’s look on your problem.
    LSB means “Linux Standard Base Core Specification” I suppose version 3.1 is the actual.

    So also your rc-script has to be complained to it.
    Of cause there are tutorials for this:
    Take this one.

    I suppose you only have to do add some commented lines in a header of your script, but read what to do exactly.

    Also since Debian 6.0 you have to use

    $insserv jboss

    instead of

    $ update-rc.d jboss defaults

    So try to improve your default script.
    If you have troubles to do it, ask me, maybe i will have some time on next weekend to help you by trying it myself on deb 6.

    So good luck and let us know ;)

  • Pingback: Installing Java 7 on Debian

  • http://alexander.holbreich.org/ shuron

    openjdk-6-jdk is is a package for Open JDK ;)
    I used Oracle (former sun) java . But meanwhile there are not much considerable difference. Not for Jboss.