Sun Java System Application Server Platform Edition 9 Quick Start Guide

Packaging and Deploying Applications

Before applications can be deployed, they must be packaged into Java ARchive (JAR), Web ARchive (WAR), or Enterprise ARchive (EAR) files. The packaged application includes deployment descriptors, which give the Application Server software the information it needs to load the application, map a URL to it, and connect it to the resources it uses. This section describes the following techniques for packaging and deploying applications:

For more information, see “Getting Started With Web Applications” in The Java EE 5 Tutorial.

Using NetBeans IDE to Develop and Deploy Applications

NetBeansTM IDE is an Integrated Development Environment you can use to create, package, and deploy complex Java EE applications. The NetBeans IDE 5.0 is available for download from NetBeans IDE integrates the development environment with the deployment environment, and automates many steps for producing Java EE applications. Once you register the Application Server with the NetBeans IDE, you can easily deploy applications, make changes, and redeploy them.

For more information on using NetBeans IDE with Application Server, see the documentation at:

ProcedureTo Package the Hello Application Using asant

If applications are not packaged with a tool such as NetBeans IDE, you can use the asant utility shipped with the product. The asant utility is used to automate repetitive deployment tasks. It is a shell script that initializes the Application Server environment and launches the Jakarta Ant tool. For more information on the asant utility, see the Sun Java System Application Server Platform Edition 9 Reference Manual, and Chapter 3, The asant Utility, in Sun Java System Application Server Platform Edition 9 Developer’s Guide.

The Hello application deployed earlier was already packaged into a WAR file. This section covers packaging the application's components into another WAR file. The build.xml file included with the Hello application contains the build targets.

  1. If you have not already added install-dir/bin to your PATH environment variable, do so now.

  2. Go to install-dir/samples/quickstart/ directory.

  3. Type asant war.

    This command assembles the WAR file for the application in install-dir/samples/quickstart/build/assemble/war.

ProcedureTo Deploy From the Admin Console

Now that you have packaged the Hello application, you can deploy it. The following section discusses deploying the Hello application using the Admin Console. You can also deploy using asant.

  1. Click http://localhost:4848/asadmin.

    • 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.

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

  6. To deploy the newly assembled Hello application, on the Web Applications page, click Deploy.

  7. Select the Package file to upload to the Application Server option and click Browse.

  8. Navigate to the install-dir/samples/quickstart/build/assemble/war directory and select hello.war.

  9. Click Next.

  10. On the Deploy Web Module page, click Finish

    The application appears in the Web Applications list.

  11. To verify that it was deployed properly, click Launch.

ProcedureTo Deploy From a Development Directory

You can deploy an application directly from a development directory, if the appropriate directory hierarchy and deployment descriptors have been created. This directory must be accessible from the machine where Application Server is installed. Because the process is complex for non-trivial applications, it is a procedure that is recommended only for advanced users, or simple applications. But when it is feasible to do so, deploying directly from a directory can speed up the development cycle.

The process can be performed interactively by using the Admin Console, or by using asadmin deploydir from the command line or in a script. The steps for the command line are presented here, because most developers want to automate the procedure in command scripts.

Note –

Before using asadmin on Windows, see To Configure the Windows Environment to Use the Command-Line Tools.

  1. In the install-dir/samples/quickstart/ directory, create a new directory called hello2/.

  2. Unzip the contents of the hello.war file into the hello2/ directory.

    Preserve the directory structure of the hello.war file when you unzip it. It is a template for the kind of file structure you need to deploy directly from a directory.

  3. If you already have a Hello application deployed, undeploy it now using the command asadmin undeploy hello at the command line.

    If you did not install the Application Server with the “Don’t prompt” option, also specify the option --user username, where username is the admin user name. You are prompted for the administration password.

  4. Use the following command to deploy the application:

    asadmin deploydir install-dir/samples/quickstart/hello2

    Note –

    Specify the full path to the hello2/ directory.

    The following message appears: Command deploydir executed successfully.

  5. Verify that the application is running by going to this URL: http://localhost:8080/hello.