Installing JBoss AS 6.0 Final on Ubuntu Server 11.04 for mere mortals

Installing JBoss Application Server isn’t easy – it’s big, clunky and documented by sexually frustrated neckbeard types who write like wannabe MIT professors. As a predominantly PHP-based developer, and Ubuntu user (i.e. one of the “unwashed masses”) this can be a bit daunting, if not outright fucking frustrating, especially because JBoss-types snob us Ubuntu types.

For this reason, I’ve compiled a guide on installing JBoss on Ubuntu Server 11.04 (this guide works fine for the desktop version of Ubuntu as well).

Preperation

First, we need to create a user that will run JBoss on your Ubuntu server – lots of services do this, like Apache is usually ran as a user called “www-data”.

$ sudo useradd -m -d /usr/local/jboss -s /bin/sh jboss

Now we need to install a Java Development Kit. For the purposes of this tutorial I’m using the Sun one, but there’s a bunch of others that exist because some other neckbeard types don’t like the Sun license.

The Sun JDK package is sun-java6-jdk, but to get access to it through apt, you have to uncomment the ‘partner’ repositories in /etc/apt/sources.list, so open that file up in nano or something and uncomment the following two lines (they’ll be near the bottom)

deb http://archive.canonical.com/ubuntu natty partner
deb-src http://archive.canonical.com/ubuntu natty partner

Once that’s done, you’ll need to update the GPG signatures on the repositories and update apt.

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 3E5C1192 && sudo apt-get update

Now you can finally install the Sun JDK

sudo apt-get install sun-java6-jdk

It probably wants to restart, so you’d better let it.

Downloading

Now we need to download JBoss – sounds easy, but there’s so many different download links on the JBoss download page that I could forgive a person for not knowing. You want to click the one that says 6.0.0.Final, and once you’ve done that, download the one that looks like jboss-as-distribution-6.0.0.Final.zip. The easiest way to do this is to just fetch it with the command

$ wget -O ~/jboss-as-distribution-6.0.0.Final.zip http://sourceforge.net/projects/jboss/files/JBoss/JBoss-6.0.0.Final/jboss-as-distribution-6.0.0.Final.zip/download

Now we can unzip it to the place JBoss recommends – /usr/local

$ sudo unzip ~/jboss-as-distribution-6.0.0.Final.zip -d /usr/local/

This will make the directory /usr/local/jboss-6.0.0.Final, which we need to do two things to: first, set its owner as that jboss user we made earlier

$ sudo chown -R jboss:jboss /usr/local/jboss-6.0.0.Final/

Second, create a simlink to it from where JBoss will expect it to be – /usr/local/jboss (deleting the actual directory first – thanks Ken)

$ sudo rm -rf /usr/local/jboss
$ sudo ln -s /usr/local/jboss-6.0.0.Final /usr/local/jboss

This is just another “best practice” thing to do, and can make upgrading/downgrading less of a hassle in the future.

Setting up service scripts

JBoss comes out of the box with service scripts (those things that live in /etc/init.d) for RedHat, SUSE, CentOS, Solaris, HPUX (whatever the fuck that is), but not Ubuntu – another serious case of neckbeard snobbery. So let’s make one.

First, copy the RedHat script and rename it ‘ubuntu’

$ sudo cp /usr/local/jboss/bin/jboss_init_redhat.sh /usr/local/jboss/bin/jboss_init_ubuntu.sh

Now open it up in your favourite text editor (I use nano – fuck you neckbeards), and make the following amendments

  • Change the JAVAPTH line so it points to just /usr/bin

JAVAPTH=${JAVAPTH:-"/usr/bin"}

  • Between the JBOSS_CONF and JBOSS_BIND_ADDR lines, add a definition for JBOSS_HOST, because if you don’t JBoss “binds” to the loopback interface and you can only access it from the server itself – nice one neckbeards. You can make this line either lots of zeros, which is like a wild-card, or a specific IP address if you only want it to be accessible from a particular network interface. Personally I believe this sort of shit is the responsibility of your firewall, and consider this sort of config totally redundant.

JBOSS_HOST=${JBOSS_HOST:-"0.0.0.0"}

Once you’ve saved it, we can now make a simlink to it from /etc/init.d

$ sudo ln -s /usr/local/jboss/bin/jboss_init_ubuntu.sh /etc/init.d/jboss

Finally, let’s add it to the system startup services, so it will run at boot (like Apache and all those kind of services do)

$ sudo update-rc.d jboss defaults

Now you can actually try firing the bitch up now by running the following command

$ sudo /etc/init.d/jboss start

On my crappy VM it takes about a minute, and it doesn’t tell you when it’s “done”, so you can follow it’s progress by seeing which ports it’s opened with the following command

$ netstat -al

You’re looking for one with :http-alt in the line. As soon as that’s up, you’re good to go.

15 thoughts on “Installing JBoss AS 6.0 Final on Ubuntu Server 11.04 for mere mortals”

  1. Thank you Casey – got further with your guide than any other web resource . Don’t see any ref to http-alt when running netstat -al ;what am I missing ? am running Desktop Ubuntu 11.04 .

    Regards , Marcus .

    1. Hmmm, not sure – http-alt is just a name for port 8080, do you see that in the netstat list? Or perhaps you’ve set it up to run on port 80 instead?

      If you run sudo netstat -al | grep 8080 it will show you only the lines from the netstat output that have 8080 in them.

  2. I had a question b/c I’m having some trouble, when I go to save the admended jboss ubuntu script in nano, I keep getting Error writing: Permission Denied. How do I get around this, this is my only hang up so far, everything else has gone smooth.

    1. You have to run nano as the super user, just run:

      sudo nano /usr/local/jboss/bin/jboss_init_ubuntu.sh

      You’ll find virtually every command in this guide has to be prepended with the sudo command. If you get sick of it, you can run sudo su which will elevate you to super user status until you run exit to get back to the normal prompt. You can tell because instead of a $ sign for the prompt, you’ll see a #.

  3. Awesome article. Referred it twice for 2 Ubuntu/JBoss installations. Followed the steps verbatim and it worked both the times. Will write an article about it on my blog referring to this link 🙂 Thanks a lot!!

  4. Hello and thank you for this well written tutorial. I did what you wrote, but when I try to start JBoss with “/etc/init.d/jboss start” there is only printed one line:
    “JBOSS_CMD_START = cd /usr/local/jboss/bin; /usr/local/jboss/bin/run.sh -c default -b 0.0.0.0”

    What could be the cause, did I miss something?

    Thank you and please keep on with your tutorials.

  5. I had to add the -m option on the useradd command. For some reason, the directory didn’t get created without it. Aside from that, good job

  6. Great guide. Only things I had to change were:
    – creating jboss user creates the jboss directory and then ln tries to link with the same name. Just delete /usr/local/jboss before creating the link
    – Need sudo on update-rc.d jboss defaults

Leave a Reply to Marcus Smith Cancel reply

Your email address will not be published. Required fields are marked *