Sun GlassFish Enterprise Server 2.1 Quick Start Guide

Chapter 3 Deploying an Application

This chapter explains how to deploy an application. If you are running a domain with developer profile, see Deploying a Sample Web Application. If you are running a domain with cluster profile, see Deploying the Sample Enterprise Application to a Cluster.

This chapter presents the following sections:

Deploying a Sample Web Application

These procedures assume that you are running a domain with developer profile.

ProcedureTo Deploy the Hello Application Using Autodeploy

The Hello application is contained in a Web ARchive (WAR) file in the samples/quickstart directory. Packaged applications can also be in the form of a Java ARchive (JAR) or Enterprise ARchive (EAR) file.

Alternatively, you can download this application from https://glasfish.dev.java.net/downloads/quickstart/hello.war.

Copying to a domain’s autodeploy directory lets you put a pre-packaged application into use immediately, with minimal effort.

  1. Find as-install/samples/quickstart/hello.war or download from https://glasfish.dev.java.net/downloads/quickstart/hello.war.

  2. Copy hello.war to the as-install/domains/domain1/autodeploy/ directory.


    Tip –

    On Windows, you can create a shortcut to the autodeploy directory on your desktop, and then drag and drop the hello.war file onto the shortcut.


    When the server has finished deploying the application, it creates a file named hello.war_deployed in the autodeploy directory. Depending on the speed of your system, the process can take a few seconds. Until that file appears, a 404-File Not Found error occurs when you try to visit the application page.

  3. Access this URL to visit the application page: http://hostname:HTTPport/hello.

    You see the application’s first page, which prompts you to fill in your name:

  4. Type your name and click Submit.

    The application displays a customized response, giving you a personal Hello.

    Hello application

ProcedureTo Deploy the Hello Application Using Admin Console

  1. Open the Admin Console in a web browser if you have not done so already.

  2. In the left pane, click the Applications node to expand it.

  3. Click Web Applications.

    You can see the list of deployed web applications, if any.

  4. Click Deploy.

  5. You can use the Hello application bundled with the Enterprise Server or you upload the sample you have downloaded from https://glassfish.dev.java.net/downloads/quickstart/hello.war. Do one of the following:

    • Select the option called Local packaged file or directory that is accessible to Application Server and click Browse Files. Navigate to the as-install/samples/quickstart directory and select hello.war.

  6. If you have downloaded the Hello application, click Browse in the Packaged File to Upload text box. Navigate to the directory to which you have downloaded the application.

  7. Click OK.

    The application appears in the Web Applications list.

  8. To verify that it was deployed properly, in the Web Applications page, select the Hello application and click Launch.

Deploying Applications Using CLI Commands

You can deploy applications using the asadmin deploy command. You can also use the asant commands for deployment. For detailed information on deploying applications see the Sun GlassFish Communications Server Application Deployment guide.

Deploying the Sample Enterprise Application to a Cluster

These procedures assume that you are running a domain with cluster profile. The procedures in this chapter assume that you have already created a cluster called default-cluster, as described in Chapter 2, Setting Up a Cluster. This section uses the clusterjsp sample application to demonstrate HTTP load balancing capabilities.

ProcedureTo Deploy the Sample Enterprise Application Using Admin Console

  1. Open the Admin Console in a web browser if you have not done so already.

  2. Click Common Tasks on the left pane to go to the Common Tasks page, if you are not there already.

  3. On the right pane, under Common Tasks, click Deploy Enterprise Application (.ear).

  4. Select the radio button to the left of the Local packaged file or directory that is accessible from the Application Server option and then click the Choose File... button. Navigate to as-install/samples/quickstart/clusterjsp/clusterjsp.ear.

    If you are accessing Enterprise Server remotely, and if the sample application is accessible from your client machine choose the Packaged file to be uploaded to the server option and click Browse.

  5. Click the Availability enabled check box to make your application highly available.

    It is recommended that you set the heap size to a larger value, if you have available memory in your system. For example, <jvm-options>-Xmx1000m</jvm-options>

  6. In the Targets section of the page, select mycluster from the Available list, and click Add to move it to the Selected list.

  7. Click OK.

    The clusterjsp application is now deployed to default-cluster. Before you launch this application, you need to start the instances in the cluster.


    Note –

    Ensure that you have enabled cookies in your browser before you deploy this application. clusterjsp is a sample application. Please use with caution in a production environment.


Deploying Applications Using CLI Commands

You can deploy applications using the asadmin deploy command. See the deploy man page in the Reference Manual. You can also use the asant commands for deployment. For detailed information on deploying applications see Deploying Modules and Applications in the Application Deployment Guide.

ProcedureTo Verify Application Deployment

  1. Type the following URL in your browser:

    http://hostname:HTTPport/clusterjsp

    Replace the hostname variable with the name of the system that the Domain Admin Server is running on.

    Replace the HTTPport variable with the value of HTTP-LISTENER-PORT for instance4. This example uses http://hostname:38081/clusterjsp.

    ClusterJSP application deployed on instance4
  2. Add some session attribute data.

  3. Examine the Session and Host information displayed. For example:

    • Executed From Server: localhost

    • Server Port Number: 38081

    • Executed Server IP Address: 198.19.255.255

    • Session Created: Tue Aug 23 15:26:07 PDT 2005

  4. Add some session data and click the Add to Session button.

  5. Repeat this procedure for instance instance3 by typing this URL in your browser:

    http://hostname :38081/clusterjsp