JBoss AS 7.1.1 on an Ubuntu 12.04 AWS Instance running Oracle Java 7

JBoss AS 7.1.1 is currently unavailable as a nicely installable Ubuntu package, officially, or as a PPA, and since I was installing it on an AWS instance, there are a couple of steps you need to do to make sure the correct ports are opened.

Setting up your AWS instance for JBoss AS

I will assume that you have created an instance, and that you have already set up SSH access rules on the Security Group that you have assigned to that instance.

Once you have got to this point, go to the Security Groups section under the NETWORK & SECURITY heading, and highlight the Security Group that is assigned to your Instance. Make sure that the Inbound tab is selected. From here, you should see a form to add a new inbound rule, as below:

AWS Console Security Group Add New Rule

You will need to add two port ranges to your Security Group:

  • 8080 for your applications.
  • 9990 for the admin interface.

To do this you will need to fill in the form above like so:

AWS Console Security Group Add Port 8080

Once it looks like this, click on “Add Rule” and move on to the next port, like so:

AWS Console Security Group Add Port 9990

Again, click on “Add Rule”, so your ports list should look like this:

AWS Console Security Group Ports List

The “Apply Rule Changes” button should now be enabled:

AWS Console Security Group Apply Changes Button

Click on the “Apply Rule Changes” to commit the new rules you’ve just added. If you don’t click on this button, the added ports will be lost when you navigate away from this page.

You have now completed the AWS setup, so let’s move on to getting a Java 7 JRE installed & configured.

Oracle Java 7 JRE on Ubuntu 12.04

To install this, we will use an Ubuntu PPA. To start with, you will need to add the PPA to your apt sources. You can do this on the command line using the following command:

  $ sudo add-apt-repository ppa:webupd8team/java
  $ sudo apt-get update
  $ sudo apt-get install oracle-java7-installer

Test this by typing in:

  $ java -version

The result should be something like this:

  java version "1.7.0_09"
  Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
  Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

Oracle Java 7 is taken care of, so we’ll move on to installing JBoss AS.

Installing JBoss AS 7.1.1

We need to start by downloading the JBoss AS binaries. We can do this using wget like so:

  $ wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz

This will download the tar file, and when it’s completed, we can uncompress it using the following command:

  $ tar -xzvf jboss-as-7.1.1.Final.tar.gz

I have chosen to install JBossAS in the /opt folder, so If you chose another location, please ensure you make this change in your own actions. We will move it into the selected location:

  $ sudo mv jboss-as-7.1.1.Final /opt

Now we need to change the listener IP for the JBoss configuration so we can access it from a remote location:

  $ sudo vim /opt/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml

You will need to find and edit the following lines (For reference, in the copy I downloaded, these were found at line #267):

  <interface name="management">
  <inet-address value="${jboss.bind.address.management:}"/>
  <interface name="public">
  <inet-address value="${jboss.bind.address:}"/>

You will need to change this to:

  <interface name="management">
  <inet-address value=""/>
  <interface name="public">
  <inet-address value=""/>

Now we are ready to test the installation, so we can just run it from the command line:

  $ /opt/jboss-as-7.1.1.Final/bin/standalone.sh

This should start up the server, and you should be able to get a JBoss AS welcome page by visiting http://xxx.xxx.xxx.xxx:8080/ where xxx.xxx.xxx.xxx is the Elastic IP/public IP of your AWS instance.

Now we just need to set up the new JBoss AS installation as a service. We will start with creating a user for the service, then changing ownership of the installation to this new user:

  $ sudo useradd -r jboss
  $ sudo chown jboss: /opt/jboss-as-7.1.1.Final/ -R

We now need to create a startup script for the service.

EDIT: As per the comment posted by blablub below, this solution apparently doesn’t work for everybody. It did work for me, but these are a couple of points to be aware of:

under [JBoss-7]/bin/init.d/ already does exist a init.d-script for jboss!

you dont have to write ur own and by the way a “jboss-admin.sh” doesnt exist under jboss 7!

To do this, we need to create a new file in the /etc/init.d/ folder:

  $ sudo vim /etc/init.d/jboss

Write the following into this new file:

  # Provides: jboss
  # Required-Start: $local_fs $remote_fs $network $syslog
  # Required-Stop: $local_fs $remote_fs $network $syslog
  # Default-Start: 2 3 4 5
  # Default-Stop: 0 1 6
  # Short-Description: Start/Stop JBoss AS v7.1.1
  #source some script files in order to set and export environmental variables
  #as well as add the appropriate executables to $PATH
  export JAVA_HOME=/usr/lib/jvm/java-7-oracle
  export PATH=$JAVA_HOME/bin:$PATH
  export JBOSS_HOME=/opt/jboss-as-7.1.1.Final
  export PATH=$JBOSS_HOME/bin:$PATH
  case "$1" in
  echo "Starting JBoss AS 7.1.1"
  #sudo -u jboss sh ${JBOSS_HOME}/bin/standalone.sh
  start-stop-daemon --start --quiet --background --chuid jboss --exec ${JBOSS_HOME}/bin/standalone.sh
  echo "Stopping JBoss AS 7.1.1"
  #sudo -u jboss sh ${JBOSS_HOME}/bin/jboss-admin.sh --connect command=:shutdown
  start-stop-daemon --start --quiet --background --chuid jboss --exec ${JBOSS_HOME}/bin/jboss-admin.sh -- --connect command=:shutdown
  echo "Usage: /etc/init.d/jboss {start|stop}"
  exit 1
  exit 0

We will need to make sure the init script is writable:

  $ sudo chmod +x /etc/init.d/jboss

Finally, we need to update rc.d with the new service script:

  sudo update-rc.d jboss defaults

You can now use this script like any other /etc/init.d script.

The following sites were useful in determining how to do this, and deserve thanks:


11 thoughts on “JBoss AS 7.1.1 on an Ubuntu 12.04 AWS Instance running Oracle Java 7

  1. Thanks for this, spent a couple of hours struggling with getting this installed, although the service part didn’t work for me. Ended up modifying the release supplied init.d script and after a couple of quick hacks, had it working happily on my ubuntu 12.04 vm.

    • I’m trying to install jboss on 12.04 vm as well. So far I haven’t got any success. Could you share us your secrets, so others could gain parts of your knowledge ?
      I really want to make this thing work!!

      • I finally made it work…

        I have changed something on your tutorial..
        At the step where you say:

        You will need to find and edit the following lines (For reference, in the copy I downloaded, these were found at line #267 more or less):

        I changed this to:

        Works fine now !

  2. under [JBoss-7]/bin/init.d/ already does exist a init.d-script for jboss!

    you dont have to write ur own and by the way a “jboss-admin.sh” doesnt exist under jboss 7!

    so ur stop command doesnt work!

    additional an application server or better said the EAR which are already deployed on it use normally other resources like a database or a ldap server. so its required to define this in the initd-startscript!

    • Thanks for that – I didn’t encounter these problems, the above worked for me, but hopefully your info will help resolve any confusion for future readers. I’ll add it in shortly.


    • Hi BOuzzi

      This really depends on what you are trying to achieve – Apache2 is a web server, this tutorial was mainly focused on just the JBoss AS side. If you want to proxy the application through a web server (there are many benefits to doing this), you would need to install Apache2 using

      sudo apt-get install apache2

      or similar, and configuring it as a proxy (mod_ajp, mod_proxy, etc. – please see http://www.tomcatexpert.com/blog/2010/06/16/deciding-between-modjk-modproxyhttp-and-modproxyajp for more info.). If you were following the steps above, please remember to open the port 80(+443 for SSL) for standard web traffic, and you should do this instead of ports 8080/9990 (I assume you don’t want the application server directly accessible to the public if you have a nice proxy in place).

      If you were not using it for a web application, and wanted a standard application server, you should ignore these steps, and NOT install Apache2.

      If you are still having troubles, please provide further information, and I’ll see what I can do to help.

      All the best!!

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s