as7_logoToday I got JBoss AS 7.1.0.CR1 fresh out of oven. The GA release is expected in next month. Full JavaEE certification is planned for this release. The following tutorial demonstrates how to set up JBoss AS7.1 on RHEL6.

Install JBoss AS7.1 on RHEL6:

Follow these five easy steps to get started with JBoss AS on RHEL6.

    1. Create User
/usr/sbin/groupadd -g 503 jboss
/usr/sbin/useradd -u 503 -m -g jboss jboss
passwd jboss
    1. Install Software

Before we install JBoss, make sure Java6 is installed and JAVA_HOME is set. JBoss AS7 installation is quite simple. You can just extract the compressed archive. To facilitate easy server upgrade, we should also create a softlink.

tar -xvf jboss-as-7.1.0.CR1.tar.gz
chown -R jboss:jboss /opt/jboss-as-7.1.0.CR1
ln -s /opt/jboss-as-7.1.0.CR1 /opt/jboss-as
    1. Start server

JBoss server could be started in standalone mode by running /opt/jboss-as/bin/standalone.sh. This binds JBoss only to localhost. To bind JBoss to another IP address, to allow remote server administration, we can change the /opt/jboss-as/standalone/configuration/standalone.xml as follows.

    <interfaces>
        <interface name="management">
            <!--<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>-->
            <inet-address value="172.xx.xxx.xx"/>
        </interface>
        <interface name="public">
            <!--<inet-address value="${jboss.bind.address:127.0.0.1}"/>-->
            <inet-address value="172.xx.xxx.xx"/>
        </interface>
    </interfaces>

However, this is not a recommended approach. Instead of modifying the central configurations, the startup customizations should be configured in bin/standalone.conf property file. Add the following lines in the configuration file.

JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address.management=172.xx.xxx.xx"
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=172.xx.xxx.xx"

By default, no users are created when you install JBoss. So lets first create a admin user with /opt/jboss-as/bin/add-user.sh. The script requires three inputs:
1. Realm – this is the name of the realm used to secure the management interfaces; default is ‘ManagementRealm’. Keep the default by pressing enter.
2. Username – the username needs to be alpha numeric. Enter ‘admin’
3. Password – Should not be same as username. Enter ‘password’.

[jboss@machine bin]$ ./add-user.sh

Enter the details of the new user to add.
Realm (ManagementRealm) :
Username : admin
Password :
Re-enter Password :
The username 'admin' is easy to guess
Are you sure you want to add user 'admin' yes/no? yes
About to add user 'admin' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'admin' to file '/opt/jboss-as-7.1.0.CR1/standalone/configuration/mgmt-users.properties'
Added user 'admin' to file '/opt/jboss-as-7.1.0.CR1/domain/configuration/mgmt-users.properties'
    1. Admin Console

Once the server is running, you can access the JBoss admin console from your desktop with the URL http://172.xx.xxx.xx:9990/console/App.html
Use the credentials admin/password to logon.

    1. Start as a Service

Now that basic setup is done, lets set up JBoss as a service. The scripts required to start JBoss as a service are available with JBoss distribution in /opt/jboss-as/bin/init.d directory. First edit jboss-as.conf by adding the entry for JBoss user as JBOSS_USER=jboss. Also modify jboss-as-standalone.sh to set the right parameters e.g. change the processname to ‘jboss’ instead of ‘standalone’. Also make sure right directories are configured for logs and pid file creation.

#!/bin/sh
#
# JBoss standalone control script
#
# chkconfig: 345 80 20
# description: JBoss AS Standalone
# processname: jboss

Now we can add JBoss as a service using chkconfig.

cp /opt/jboss-as/bin/init.d/jboss-as.conf /etc/jboss-as/
chmod 755 /opt/jboss-as/bin/init.d/jboss-as-standalone.sh
cp /opt/jboss-as/bin/init.d/jboss-as-standalone.sh /etc/init.d/jboss
chkconfig --add jboss

Once these configurations are done, JBoss can be started as a service with following commands. Make sure there are no errors in console.log.

#Start JBoss
service jboss start
#Stop JBoss
service jboss stop
#Restart JBoss
service jboss restart

Conclusion:
In this introductory blog post about JBoss AS, I’ve demonstrated how to install JBoss on RHEL6 and configure JBoss as a service.