Starting JBoss 5.1 automatically in FreeBSD 7.2

I have used the ports collection to install JBoss 5.1 on my FreeBSD 7.2 Box. The installation went well and as usual, the ports installation process did all the downloading and compiling of the package and its dependencies.

After installation, I need to test it to start developing. So I did a command to start it

All works well and JBoss starts. I opened a browser in my local machine and visited and the JBoss start page is loaded.

Next thing I have to do is to access JBoss on a different machine.

I then used my netbook to access http://192.168.0.***:8080 to my surprise, I didn’t get a response and an error message was displayed in my browser. I then searched the web for an answer. After a couple of links I was able to get an answer. I need to start JBoss with the option -b supplied to the script By default JBoss is binded to, meaning only the local machine can access it. So I have to find a way to start JBoss passed with that option.

Here are the steps to make JBoss automatically started on boot:
1. Add these lines at the end of /etc/rc.conf

2. The default jboss5 script in the /usr/local/etc/rc.d directory does not work with -b Therefore, you have to replace it by the /usr/local/jboss5/bin/ script. After replacing it, the “start” “stop” and “restart” options does not work with the script, but if you want to, you are free to edit the script to include it.
mv /usr/local/etc/rc.d/jboss5 /usr/local/etc/rc.d/jboss5-original-script
cp /usr/local/jboss5/bin/ /usr/local/etc/rc.d/jboss5

3. Create a bin directory at the /usr/local/etc/
mkdir /usr/local/etc/bin

4. Make a symlink for /usr/local/jboss5/bin/run.jar inside /usr/local/etc/bin
ln -s /usr/local/jboss5/bin/run.jar /usr/local/etc/bin/jbossrun.jar

5. Edit /usr/local/etc/rc.d/jboss5 so that jbossrun.jar will be the file needed to start it
vi /usr/local/etc/rc.d/jboss5

6. Find the line runjar=”$JBOSS_HOME/bin/run.jar” and replace it with runjar=/usr/local/etc/bin/jbossrun.jar

7. Run jboss by using (this does not include the start, restart, and stop options, again if you want to, you are free to edit the script to fit your needs)

8. On your next restart of FreeBSD, JBoss will start and will be accessible to other machines.