Sun Java System Application Server 9.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 server installation includes a pre-packaged application that says “Hello,” taken from The Java EE 5 Tutorial. 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 The Java EE 5 Tutorial or from http://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 http://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://localhost:4848/hello.

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

    Displays message: Hi, my name is Duke. What's yours?
  4. Type your name and click Submit.

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

ProcedureTo Deploy the Hello Application Using Admin Console

  1. Open http://localhost:4848/asadmin in a web browser.

    • localhost is used if the both the browser and the Application Server are running on the same system. If the Application Server is running on another system, substitute the name of that system in the URL.

    • 4848 is the Admin Console’s default port number. If you changed the port number during the installation, use that number instead.

  2. Enter the admin user name and password.

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

  4. Click Web Applications.

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

  5. If you already have a Hello application deployed, undeploy it now by selecting the checkbox next to it and clicking Undeploy.

  6. Click Deploy.

  7. You can use the Hello application bundled with the Application Server or you upload the sample you have downloaded from http://glasfish.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.

  8. If you have downloaded the Hello application Select the Package file to upload to the Application Server option and click Browse. Navigate to the directory to which you have downloaded the application.

  9. Click OK.

    The application appears in the Web Applications list.

  10. 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. See deploy(1) in the Sun Java System Application Server 9.1 Reference Manual. You can also use the asant commands for deployment. For detailed information on deploying applications see Deploying Modules and Applications in Sun Java System Application Server 9.1 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 cluster1, as described in Chapter 2, Setting Up a Cluster.

This sample application is provided to demonstrate the clustering capabilities using session information. One has to exercise caution for use in production.

ProcedureTo Deploy the Sample Enterprise Application Using Admin Console

  1. Click the Home button or click Common Tasks on the left pane to go to the Common Tasks page, if you are not there already.

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

  3. If application server is installed on your local machine, click Browse in the Packaged File to Upload text box, and navigate to as-install/samples/ee-samples/highavailability/apps/clusterjsp/clusterjsp.ear. If you are accessing Admin Console remotely with application server installed on another machine, click Browse in the Local packaged file or directory that is accessible from the Application Server text box. Navigate to as-install/samples/quickstart/clusterjsp/clusterjsp.ear.

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

  5. Click OK.

    The clusterjsp application is now deployed to cluster1. Before you launch this application, you need to start the instances in the cluster. See To Start the Instances in a Cluster

Deploying Applications Using CLI Commands

You can deploy applications using the asadmin deploy command. See deploy(1) in the Sun Java System Application Server 9.1 Reference Manual. You can also use the asant commands for deployment. For detailed information on deploying applications see Deploying Modules and Applications in Sun Java System Application Server 9.1 Application Deployment Guide.

ProcedureTo Start the Instances in a Cluster

Before you launch the deployed application, you need to start the instances in the cluster.

  1. In the tree on the left pane, click Clusters, and click the cluster1 node.

  2. In the right pane, navigate to the General tab if it is not already active.

  3. If the instances are not already running, the Start Instances button is active. Click it to start the cluster's instances.

  4. Verify that they have started by checking the Status field, which indicates how many instances are running.

    You are now ready to launch the application. See To Start the Instances in a Cluster

Starting Instances Using CLI Command

You can start instances by using the asadmin start-intance command. See in the Sun Java System Application Server 9.1 Reference Manual.

ProcedureTo Verify Application Deployment

  1. Type the following URL in your browser:

    http://localhost:port/clusterjsp

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

    Replace the port variable with the value of HTTP-LISTENER-PORT for instance1. This example uses http://localhost:38081/clusterjsp.

  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 instance2 by typing this URL in your browser:

    http://localhost :38080/clusterjsp

Next Steps

Congratulations! You have completed this section of the Quick Start Guide. You can stop the Quick Start trail here if you do not wish to proceed to the steps on load balancing.