JBoss 7 Application Deployment with Apache Web Server


Applicable Plans - All Cloud Hosting Plans

JBoss 7 application deployment with Apache Web Server

Overview

Using the eApps Virtual Server in the Cloud Hosting service, Java SE 6 or Java SE 7, and JBoss 7, you can create web sites and web applications with dynamic content for your customers and users.

This User Guide is designed to help you deploy your JBoss 7 applications using the Apache web server and either mod_jk or mod_proxy_ajp.

Reading the Installation and Tuning User Guide is a prerequisite for this User Guide, because the things covered in that User Guide are generally not covered again here, such as how to stop, start, or restart JBoss, how to set JBoss to start after system boot, and how to access the JBoss 7 Administration Console.

Pay careful attention to the resources allocated to your Virtual Server when deploying JBoss 7 applications, especially the available RAM. JBoss can be very memory intensive, and a lack of resources is one of the main reasons for poor performance. For a small JBoss application, start with at least 1024 MB of RAM, and be prepared to scale upwards as necessary. For larger JBoss applications, start with at least 1536 MB of RAM, and again be ready to scale upwards if your traffic and resource needs demand it.

If you do not need the advanced features of JBoss 7, and just need support for JSP and Servlets, we recommend that you uninstall JBoss and install Tomcat instead, as Tomcat uses less resources and is not as complex as JBoss to configure and use.

JBoss 7 is a very complex and powerful application that is intended for advanced users who are deploying enterprise grade applications. Before deploying your applications with JBoss, make sure that you really need all the complexity that JBoss provides. To make the best use of JBoss you need to be an expert in Java application programming and deployment.

Installing JBoss 7

Deployment examples using JBoss 7 with Apache

Apache as a front end to JBoss using mod_jk
    mod_jk Directives
    mod_jk Syntax Overview
    Deployment examples using mod_jk
    Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp, Apache serving all other content using mod_jk
    Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com, Apache serving all other content using mod_jk

Apache as a front end to JBoss using mod_proxy_ajp
    Deployment examples using mod_proxy_ajp
    Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp, Apache serving all other content using mod_proxy_ajp
    Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com, Apache serving all other content using mod_proxy_ajp

Deploying your application using the JBoss 7 Administration Console


Installing JBoss 7

Information and instructions on installing JBoss 7 and related applications can be found in the JBoss 7 Installation and Tuning Guide. Make sure you have read that guide before starting to deploy your applications.


Deployment examples using JBoss 7 with Apache

Using the JBoss 7 Administration Console, you can deploy your application WAR file and set up your Virtual Host. However, for this to work, you will have to have a jboss-web.xml file in the WEB-INF directory in your WAR file with the correct context-root and virtual-host settings.

These examples use a domain of eapps-example.com, and an application named mywebapp. You will need to substitute your own domain and application names where appropriate.

There are four deployment approaches using mod_jk and mod_proxy_ajp:

  1. Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp, Apache serving all other content using mod_jk

  2. Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com, Apache serving all other content using mod_jk

  3. Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp, Apache serving all other content using mod_proxy_ajp

  4. Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com, Apache serving all other content using mod_proxy_ajp


In each case, the way to deploy (upload) the file and set up the Virtual Host in the JBoss Administration Console is the same. See the section of this User Guide titled Deploying your application using the JBoss 7 Administration Console for more information.

What differs is the configuration of the jboss-web.xml file and the additional settings that are needed for the Apache configuration file that are specific for either mod_jk or mod_proxy_ajp.


Apache as a front end to JBoss using mod_jk

mod_jk is used to forward requests from Apache to JBoss. Apache runs securely on port 80, and JBoss runs securely on port 8080. This means that by default, the URL of your application would either be http://eapps-example.com:8080 or http://eapps-example.com:8080/webapp.

With mod_jk, you are able to run JBoss securely on port 8080 and have Apache forward requests to JBoss. This eliminates the 8080 from the URL. This means the URL for your application can now be either http://eapps-example.com or http://eapps-example.com/webapp.

mod_jk Directives

When mod_jk is installed, default directives are created in /etc/httpd/conf.d/mod_jk.conf. These are the default mod_jk directives:

JkMount /*.jsp ajp13
JkMount /*.do ajp13
JkMount /admin* ajp13
JkMount /manager* ajp13
JkMount /web-console* ajp13
JkMount /jmx-console* ajp13

mod_jk also offers no-jk directives, which allow requests for applications such as SquirrelMail or AWStats to bypass JBoss so they can be served directly by Apache. The no-jk directives are added in the same way as the mod_jk directives. Examples of no-jk directives are given as part of the mod_jk examples in the deployment examples that follow.

mod_jk Syntax Overview

The standard format for a mod_jk directive is:

JkMount /servlet* ajp13
  • JkMount – this is the JkMount directive that calls mod_jk

  • /servlet - this is the regular expression(regex) that is matched in the referring URL and is passed to the servlet container. Typically, this is the only part of a JkMount directive you will change

  • ajp13 – this is the internal handler that will receive the request.

The above directive will pass all URLs with a suffix of /servlet to the ajp13 handler and the request will be handled by JBoss. A URL with a suffix of /mail will still be handled by Apache.

Adding mod_jk directives from a Control Panel

You can add the mod_jk directives to serve applications that require Apache from your Control Panel.

Using the ISPmanager Control Panel

How to add mod_jk directives to the ISPmanager Control Panel will depend on which version of ISPmanager you are using. Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions

  • ISPmanager 4 - go to Domains > WWW Domains and select the domain where you want to add the mod_jk directives. Click on Config, and then add your mod_jk directives near the end of the file, just above the closing </VirtualHost> tag. More information about managing WWW Domains in ISPmanager 4 can be found here - Managing WWW Domains

  • ISPmanager 5 - go to Domains > Web-domains and select the domain where you want to add the no_jk directives. Click on Config, and then add your mod_jk directives near the end of the file, just above the closing </VirtualHost> tag. More information about managing Web-domains in ISPmanager 5 can be found here - Managing Web-domains

Once you have added your mod_jk settings, click Ok. This will reload Apache so that the new settings are read.

Using the Command Line

If you are comfortable working with the Apache httpd.conf file directly, you can add your mod_jk directives directly at the end of the VirtualHost block for the website, and then restart Apache.


Due to the complexity of JBoss, it is impossible to give exact instructions for some of these examples, especially in the case of the jboss-web.xml and application.xml files! Keep in mind that these are only examples; you will need to work with your JBoss developer or consult the official JBoss documentation to determine the exact settings for some of these files.


Deployment examples using mod_jk

Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp, Apache serving all other content using mod_jk

This deployment example assumes you have a WAR file called mywebapp.war, using a Virtual Host of eapps-example.com.

For this deployment approach to work, you will need to add the following in your WEB-INF/jboss-web.xml file:

<jboss-web>
    <context-root>/mywebapp</context-root>
    <virtual-host>eapps-example.com</virtual-host>
</jboss-web>

 

The mod_jk directives in this example will serve all applications provided by eApps but forward requests to /mywebapp to JBoss. Add the following mod_jk directives to the Apache config for the web site either from your Control Panel or from the command line.

JkMount /mywebapp* ajp13

Once you have added your mod_jk settings, reload or restart Apache.

Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com, Apache serving all other content using mod_jk

This deployment example assumes you have a WAR file called mywebapp.war, using a Virtual Host of eapps-example.com.

For this deployment approach to work, you will need to add the following in your WEB-INF/jboss-web.xml file:

<jboss-web>
    <context-root>/</context-root>
    <virtual-host>eapps-example.com</virtual-host>
</jboss-web>

 

The mod_jk directives in this example will serve all applications provided by eApps but forward all other requests to JBoss. Add the following mod_jk directives to the Apache config for the web site either from your Control Panel or from the command line.

JkMount /* ajp13
# Directives to enable Apache to continue serving applications dependent on it.
SetEnvIf Request_URI "/webmail*" no-jk
SetEnvIf Request_URI "/awstats*" no-jk
SetEnvIf Request_URI "/myadmin*" no-jk
SetEnvIf Request_URI "/pgadmin*" no-jk
SetEnvIf Request_URI "/cgi-bin*" no-jk
SetEnvIf Request_URI "/joomla*" no-jk
SetEnvIf Request_URI "/wordpress*" no-jk
SetEnvIf Request_URI "/drupal*" no-jk
SetEnvIf Request_URI "/mailman*" no-jk

Once you have added your mod_jk settings, reload or restart Apache.

Control Panel Configuration

ISPManager 4 Control Panel

Make a note of these three "no-jk" directives:

SetEnvIf Request_URI "/manager/ispmgr*" no-jk
SetEnvIf Request_URI "/manimg*" no-jk
SetEnvIf Request_URI "/mancgi*" no-jk

These are the directives that allow the ISPmanager 4 Control Panel to still be available, even if everything else is being forwarded to JBoss. These must be included if you still want to use ISPmanager.


Apache as a front end to JBoss using mod_proxy_ajp

mod_proxy_ajp is used to forward requests from Apache to JBoss. Apache runs securely on port 80, and JBoss runs securely on port 8080. This means that by default, the URL of your application would either be http://eapps-example.com:8080 or http://eapps-example.com:8080/webapp.

With mod_proxy_ajp, you are able to run JBoss securely on port 8080 and have Apache forward requests to JBoss. This eliminates the 8080 from the URL. This means the URL for your application can now be either http://eapps-example.com or http://eapps-example.com/webapp.

mod_proxy_ajp is an extension of the mod_proxy module that is available in Apache 2.2. The required modules are installed automatically as part of the Apache web server. As with mod_jk, the mod_proxy_ajp directives must be specified in Edit Directives or directly in httpd.conf for each site.

Adding mod_proxy_ajp directives from a Control Panel

You can add the mod_proxy_ajp directives to serve applications that require Apache from your Control Panel.

Using the ISPmanager Control Panel

How to add mod_proxy_ajp directives to the ISPmanager Control Panel will depend on which version of ISPmanager you are using. Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions

  • ISPmanager 4 - go to Domains > WWW Domains and select the domain where you want to add the mod_proxy_ajp directives. Click on Config, and then add your mod_proxy_ajp directives near the end of the file, just above the closing </VirtualHost> tag. More information about managing WWW Domains in ISPmanager 4 can be found here - Managing WWW Domains

  • ISPmanager 5 - go to Domains > Web-domains and select the domain where you want to add the mod_proxy_ajp directives. Click on Config, and then add your mod_proxy_ajp directives near the end of the file, just above the closing </VirtualHost> tag. More information about managing Web-domains in ISPmanager 5 can be found here - *Managing Web-domains8

Once you have added your mod_proxy_ajp settings, click Ok. This will reload Apache so that the new settings are read.

Using the Command Line

If you are comfortable working with the Apache httpd.conf file directly, you can add your mod_proxy_ajp directives directly at the end of the VirtualHost block for the web site, and then restart Apache.


Due to the complexity of JBoss, it is impossible to give exact instructions for some of these examples, especially in the case of the jboss-web.xml and application.xml files! Keep in mind that these are only examples; you will need to work with your JBoss developer or consult the official JBoss documentation to determine the exact settings for some of these files.


Deployment examples using mod_proxy_ajp

Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp, Apache serving all other content using mod_proxy_ajp

This deployment example assumes you have a WAR file called mywebapp.war, using a Virtual Host of eapps-example.com.

For this deployment approach to work, you will need to add the following in your WEB-INF/jboss-web.xml file:

<jboss-web>
    <context-root>/mywebapp</context-root>
    <virtual-host>eapps-example.com</virtual-host>
</jboss-web>

 

The mod_proxy_ajp directives in this example will serve all applications provided by eApps but forward all requests for /mywebapp to JBoss. Add the following mod_ajp directives to the Apache config for the web site either from your Control Panel or from the command line.

ProxyPass /mywebapp ajp://localhost:8009/mywebapp

Once you have added your mod_proxy_ajp settings, reload or restart Apache.

Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com, Apache serving all other content using mod_proxy_ajp

This deployment example assumes you have a WAR file called mywebapp.war, using a Virtual Host of eapps-example.com.

For this deployment approach to work, you will need to add the following in your WEB-INF/jboss-web.xml file:

<jboss-web>
    <context-root>/</context-root>
    <virtual-host>eapps-example.com</virtual-host>
</jboss-web>

 

The mod_proxy_ajp directives in this example will serve all applications provided by eApps but forward all other requests to JBoss. Add the following mod_proxy_ajp directives to the Apache config for the web site either from your Control Panel or from the command line.

# Directives for your application
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
# Directives for eApps applications dependent on Apache
ProxyPass /webmail !
ProxyPass /joomla !
ProxyPass /awstats !
ProxyPass /myadmin !
ProxyPass /cgi-bin !
ProxyPass /pgadmin !

Once you have added your mod_jk settings, reload or restart Apache.

Control Panel Configuration

ISPManager 4 Control Panel

Make a note of these three "mod_proxy_ajp" directives:

ProxyPass /manager/ispmgr !
ProxyPass /manimg !
ProxyPass /mancgi !

These are the directives that allow the ISPmanager Control Panel to still be available, even if everything else is being forwarded to JBoss. These must be included if you still want to use ISPmanager 4.


Deploying your application using the JBoss 7 Administration Console

Once you have the jboss-web.xml file set up, you can package your WAR file and then deploy the application. To do this, log in to the JBoss 7 Administration Console. See the User Guide: JBoss 7 Install and Tuning - JBoss 7 Administration Console - http://support.eapps.com/ispmgr/jboss7-install#jboss-7-administration-console for more information on how to access the Administration Console.

Once you are logged in to the Administration Console, go to Deployments > Manage Deployments.

Manage Deployments


In the Deployments screen, click on Add Content.

Add Content


This opens the Upload screen, on the Deployment Selection page. Click on Choose File, and browse your local computer for the WAR file you wish to upload.

Deployment Selection

Once you have selected the WAR file, click Next.


This takes you to the Verify Deployment Names page. This will show you the Key, Name, and Runtime Name of the WAR file that you selected. Leave these selections as they are, make no changes here.

Verify Deployment Names

Click on Save.


This takes you back to the Deployments page, where you can see the WAR file that was just uploaded. Note that it is currently disabled (there is a NO symbol under the Enabled column).

Do not enable the application at this point.

Deployments - Disabled


Before enabling the application, you need to set up the Virtual Server for the domain name that the application is going to answer on. To do this, click on Profile at the top right of the screen, and then click on the plus sign [+] next to Web in the left navigation pane, and then on Servlet/HTTP. Then click on the Virtual Servers tab. That will open the screen seen below.

Servlet - Virtual Servers

To add the Virtual Server, click on Add.


This opens the Create Virtual Server screen. This is where you define the domain name, the alias, and the application.

Create Virtual Server
  • Name - this is the domain name that the application is hosted on. Note that the Fully Qualified Domain Name (FQDN) is used here (in this example, eapps-example.com).

  • Alias - if the application is also going to be available on an alias, such as www.eapps-example.com, then enter the alias here.

  • Default Module - this is the name of the WAR file you uploaded. Note that the full name of the file is needed, including the file extension.

Once you have entered the information, click on Save.


This takes you back to the Virtual Servers tab of the Servlet/HTTP screen, where you can see your new Virtual Server added.

Virtual Servers - Added

 

Now you need to enable your application so that it is available. Click on Runtime at the top right of the screen, and then go to Deployments* >Manage Deployments*. Then click on Enable.

Enable application


This brings up the Are you sure? screen.

Are you sure?

Click Confirm to enable the application. The NO symbol under the Enabled column will now be a check mark.

Application Enabled


At this point your application is enabled and available. Test by going to the URL defined by your deployment method. If you have any issues, please contact eApps Support for assistance.



Comments

Please login to comment