Running JBoss AS 7 on Amazon EC2

This is a quick set of steps to get JBoss AS 7 running on a SUSE Linux Enterprise Server 11 instance. These are not necessarily best practices, especially the firewall settings. But, if you want to quickly get started playing with JBoss, this article will save you a bit of hassle.

Step 1: First install JDK7. I couldn’t get a clean URL that I could use with curl to download the RPM directly from the EC2 instance. So, I had to first download the RPM from Oracle to my Windows desktop and upload it to my EC2 instance using SFTP. Then install the JDK:

rpm -Uvh jdk-7u5-linux-x64.rpm

Step 2: Then, install JBoss 7. This one is a bit easier. First, get the distribution using the curl command.

curl -o \

Then just unzip the file.


Step 3: This step is optional. I was using a micro instance, so the memory is really low. I had to tweak Java’s memory setting to get JBoss to start. This may not be necessary, if you have more memory available. Open <JBOSS>/bin/standalone.conf. Drastically lower the memory settings as shown in bold face.

JAVA_OPTS="-Xms64m -Xmx86m -XX:MaxPermSize=64m ...

As I said, this sets the memory limits to ridiculously low values and are useless to run a real web site.

If system runs out of memory, you may see this error message, when you start JBoss.

# There is insufficient memory for the Java Runtime Environment to continue. 
# Native memory allocation (malloc) failed to allocate 128 bytes for CHeapObj-nw

Step 4: Now, we have to play with the firewall settings. First, we have to configure JBoss to use the Ethernet interface to listen for incoming requests. Without that, you will be able to use the applications from within the instance only. The name of the Ethernet interface should be eth0. If you are not sure, just run the ifconfig command to find out. Then open <JBOSS>/standalone/configuration/standalone.xml. Within the <interfaces> element, add a new <interface> element as follows:

        <interface name="external">
                <nic name="eth0"/>

Then, use the interface from various socket bindings.

<socket-binding name="management-http" interface="external" 
<socket-binding name="management-https" interface="external" 
<socket-binding name="ajp" interface="external" port="8009"/>
<socket-binding name="http" interface="external" port="8080"/>
<socket-binding name="https" interface="external" port="8443"/>

Caveat: In real life, you may not want to allow connection to the admin console from the Internet.

Step 5: Create a JBoss administrator user by running the <JBOSS>/bin/ command. Just enter a user name and password, and accept all other defaults.

Step 6: Finally, for the security group of your EC2 instance, open up port 8080 and 9990.

Step 7: Start the server by running <JBOSS>/bin/

Now, you should be able to use a web browser from your desktop and access http://EC2_HOSTNAME:8080. The admin console is at http://EC2_HOSTNAME:9990/console.

You can shutdown the server by running this from <JBOSS>/bin.

./ --connect command=:shutdown

You probably want the server to start when the EC2 instance boots up. JBoss 7.1 ships with an init.d script for a standalone system. This is located in <JBOSS>/bin/init.d/ But, frankly, I found the script to be plain strange. You can roll your own by following some of the ideas in this post.

Create a script called, say, jboss in /etc/init.d directory.

Then run tis command to configure the script as init.d script:

chkconfig --add jboss

Reboot the instance and make sure that JBoss server starts up.

7 thoughts on “Running JBoss AS 7 on Amazon EC2

  1. JAVA_OPTS=”-Xms64m -Xmx86m -XX:MaxPermSize=64m ..

    Hello can you please complete the line after the true. this article is really helping me i started using AWS recently installed Jboss but struck with memory error. The above line looks like the solution for it. Thank you

  2. Hi ! it’s a good tutorial . But i got a new problem. After i create JBOSS AS7 as a service it worked for a few minutes . then suddenly I can’t access that page. it tells connection time out . Even i can’t log in to ec2 instance through putty .can you help on this pls ? .

Leave a Reply

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

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