I frequently get asked about setting up and using JBoss, so I thought I’d write a bit about it, just in case it helps anybody out there. In this first post I’ll just show you how to get JBoss AS up and running. In later posts I’ll get into more details, and show you how to set up things like JBoss Portal. I’m doing this on a Debian Etch system, but the instructions should more or less apply across Linux/UNIX systems.
What about JBoss in the Debian repositories?
If you feel like giving it a try do:
# aptitude install jbossas4
But, it won’t do much (at least they didn’t last time I tried). The JBoss packages in Debian need some work before they become usable. (I’m not sure about the status in Sid.)
Before you do anything else, you need to have Java installed. I’m using Sun’s JDK 6, and that seems to work fine. JDK5 should also work.
Go here and grab a copy of JBoss AS. Latest stable at this time of writing is 4.2.2 GA. (I’ll probably do a post on JBoss 5 at some point.) When you get to the Sourceforge page, make sure you grab the correct package. The packages with src in their names are source packages. Only download them if you want to compile JBoss yourself. I will assume you don’t.
Once you have downloaded JBoss AS, you need to extract it. I chose to do so into /opt. The following needs to be done as root:
# cd /opt # unzip /home/lorenzod/dl/jboss-4.2.2.GA.zip
After a few seconds it should be done, and ls will show you that there is a new directory called jboss-4.2.2.GA. If you want you can change the name of the directory to jboss, jboss4 or whatever makes you happy. I’ll keep the name as it is.
Testing the server
To make sure everything is fine up to this point, let’s try to start the server.
# cd /opt/jboss-4.2.2.GA # bin/run.sh
You should see loads of log messages flying by in your terminal. That is normal. Eventually you will see a message like this:
22:31:21,073 INFO [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 14s:615ms
Note that by default JBoss will only listen on 127.0.0.1 (localhost), which means it’s only accessible from the computer you are running JBoss on. To make it listen to other interfaces as well restart the server like this (you can press CTRL+C to stop JBoss if it s running):
# cd /opt/jboss-4.2.2.GA # bin/run.sh -b 0.0.0.0
This will make JBoss listen on all the network interfaces. If you only want it to listen on a specific interface, use that IP address after the -b, for example bin/run.sh -b 192.168.0.5 will make JBoss only listen on the IP address 192.168.0.5.
Next, open a browser. If your browser is on the same machine as JBoss AS, you can browse to http://localhost:8080. Otherwise you’ll have to use either the name of the machine or its IP address. I’ve got JBoss running on 192.168.0.5 and that machine is known as devel in our local DNS, so I can access JBoss as by either http://192.168.0.5:8080 or http://devel:8080.
If you get a page server by JBoss then everything is working. Otherwise, you will have to go back and make sure you didn’t leave something out.
Eventually, you will want to add something like this into your ~/.zshrc (or whichever start-up files your $SHELL uses):
IIRC, the JBoss documentation also suggests you add $JBOSS_HOME/bin to your PATH. I don’t personally do that because the names of the scripts in that directory are too generic (run.sh, shutdown.sh etc). But if you like you can do this somewhere (~/.zshenv is a good idea):
Obviously you would have to set JBOSS_HOME before this is executed, otherwise you’ll have problems. You might want to rename the scripts to jboss-run.sh, jboss-shutdown.sh, etc.
I have shown how to install JBoss and get it up an running. It won’t start automatically when you boot the server yet. You will need an init script for that. I will get to that soon.
Note that there isn’t all that much interesting you can do with the application server yet. In order to make it more interesting you will need to develop some applications for it, or install some existing ones. Next time, I’ll look at how to set up JBoss Portal.