Running JBoss AS 7 on Port 80

Finally, we are ready to take VikingoGames.com site live. Before, it was running as a static site out of Amazon S3. Now, it will run as a web app from JBoss AS 7.1.1. Basic steps to get this done are as follows:

  1. Create an elastic IP in Amazon AWS Console.
  2. Assign the elastic IP to the EC2 instance where JBoss is running.
  3. Stop Apache and disable the service so it doesn’t start automatically. This will avoid conflict over port 80.
  4. Make JBoss listen on port 80.

In this article, I will document step #3 and #4.

Disable Apache

Go to /etc/init.d. Run this to shutdown Apache.

./apache2 stop

Disable Apache service using this command:

chkconfig apache2 off

Verify that Apache is disabled by running:

chkconfig --list apache2

The service should be turned off for all run levels and the command should show:

apache2                   0:off  1:off  2:off  3:off  4:off  5:off  6:off

Make WebLogic Listen on Port 80

First, shutdown JBoss, if it is running:

./jboss-cli.sh --connect command=:shutdown

Open <JBOSS>/standalone/configuration/standalone.xml. Locate the line:

<socket-binding name="http" interface="external" port="8080"/>

Change it to:

<socket-binding name="http" interface="external" port="80"/>

Save changes.

Start JBoss. Test the site by accessing it over port 80.

Reboot the instance to verify that Apache is disabled and there is no port conflict.

Configure Automatic Publishing from Eclipse for JBoss AS 7

By default, when you develop for JBoss 7 using Eclipse, changes to Java class and JSP don’t get automatically published. You have to right click the web module in the Servers view and select Full Publish for the changes to take effect. This can be really painful after a while. I found these steps to fix the problems.

Publish Java Class Changes

In Eclipse, double click JBoss server in the Servers view. Under Publishing select Automatically publish when resource changes. Under Application reload behavior, select Customize application reload behavior. Enter the following regular expression pattern.

\.jar$|\.class$

Save changes and restart the server. Now, when you save a Java file, system will automatically restart the application so that the changes take effect.

Publish JSP Changes

This one takes a little more work. Essentially, JBoss 7.1.1 has a defect where changes to JSP file are not picked up by the server even in development mode.

First, we need to enable JSP debug mode. Open the server’s standalone.xml. Locate the line:

<subsystem xmlns="urn:jboss:domain:web:1.1" ...>

Below that add these lines:

<configuration>
 <jsp-configuration development="true"/>
</configuration>

Save and close the file.

Download the fixed jboss-as-web-7.1.1.Final-RECOMPILE.jar file from this web site. Save the file in jboss-as-7.1.1.Final/modules/org/jboss/as/web/main folder.

In the same folder there is a module.xml file. Open it. Comment out the buggy file and use the new file as shown below.

<!--
<resource-root path="jboss-as-web-7.1.1.Final.jar"/>
-->
<resource-root path="jboss-as-web-7.1.1.Final-RECOMPILE.jar"/>

Save and close the file.

Restart the server. Now, changes to JSP will take effect immediately.