JBoss 7 application deployment without Apache


Applicable Plans - All Cloud Hosting Plans

JBoss 7 Application Deployment without 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 applications in Standalone mode, without Apache.

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, 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 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

JBoss Application Deployment without Apache

Setting up JBoss to run without Apache
    Changing the Apache port
    Add the port 80 redirect

Deployment Examples using JBoss 7 without Apache
    Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp
    Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com

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.


JBoss Application Deployment without Apache

JBoss includes its own web server, so Apache is not technically needed. It is possible to run JBoss without Apache.

This approach is best suited when the Virtual Server is only going to be used to run this application, and nothing else. This is because any of the applications that rely on Apache and PHP, such as any of the webmail applications, AWStats, phpMyAdmin, etc, will not be available.

This approach is for users who are very familiar with JBoss and Linux server configuration. Most users will see no benefit by using this approach.


Setting up JBoss to run without Apache

JBoss cannot run on port 80 because root privileges are required. Since JBoss does not have the ability to start as root, bind to port 80, then switch back to a user without administrative privileges it would have to run as root. This creates a security issue for your system.

To use JBoss in Standalone mode, you will need to add a file to the /etc/xinted.d directory that will keep JBoss running on port 8080, and have any requests to port 80 redirected to JBoss.

You will also need to change the port that the Apache web server listens on, so that you can continue to keep the Apache server running.

All of this must be done from the command line of the Virtual Server, as the root user. See the User Guide: SSH - http://support.eapps.com/ispmgr/ssh for more information if needed.

Changing the Apache port

Change directories to /etc/httpd/conf, and make a backup of the existing httpd.conf file. Then open the httpd.conf file with a text editor (vim and nano are available).

[root@eapps-example ~]# cd /etc/httpd/conf
[root@eapps-example conf]# cp httpd.conf httpd.conf.orig
[root@eapps-example conf]# vim httpd.conf

Find the Listen directive in the file. This is generally around line 134 in an unmodified httpd.conf file.

By default, this is set to port 80.

#Listen 12.34.56.78:80
Listen 80

Change this to port 81, and save and exit the file.

#Listen 12.34.56.78:80
Listen 81

Once you have done this, restart Apache with the service httpd restart command.

[root@eapps-example conf]# service httpd restart

Add the port 80 redirect

Once you have set up Apache to listen on a different port, change directories to /etc/xinetd.d, and create the jboss file:

[root@eapps-example ~]# cd /etc/xinetd.d
[root@eapps-example xinetd.d]# vim jboss

Using a text editor (this example uses the vim editor), add these lines to the jboss file:

# Redirects any requests on port 80
# to port 8080 (where JBoss is listening)
service http
{
socket_type = stream
user = root
wait = no
redirect = localhost 8080
disable = no
}

Save and exit the file, and then restart the xinetd service with the service xinted restart command.

[root@eapps-example xinetd.d]# service xinetd restart

Now the Apache web server is listening on port 81, and all requests for port 80 will be redirected to port 8080.


Deployment Examples using JBoss 7 without 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 two deployment approaches when using standalone mode:

  1. Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp

  2. Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com

In both cases, 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.

Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com/mywebapp

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>

Deployment with JBoss 7 serving JSP and Servlets using a WAR file at eapps-example.com

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>


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