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
/usr/local/jboss5/bin/run.sh

All works well and JBoss starts. I opened a browser in my local machine and visited http://127.0.0.1:8080 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 0.0.0.0 supplied to the script run.sh. By default JBoss is binded to 127.0.0.1, 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
jboss5_enable="YES"
jboss5_flags="-Djboss.bind.address=0.0.0.0"

2. The default jboss5 script in the /usr/local/etc/rc.d directory does not work with -b 0.0.0.0. Therefore, you have to replace it by the /usr/local/jboss5/bin/run.sh 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/run.sh /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)
/usr/local/etc/rc.d/jboss5

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

Enjoy!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s