Sun Java System Application Server Platform Edition 8.2 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 J2EE 1.4 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 2 Platform, Enterprise Edition (J2EE platform) applications. The NetBeans IDE is available for download from NetBeans IDE integrates the development environment with the deployment environment, and automates many steps for producing J2EE 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 NetBeans IDE, see the documentation at:

ProcedureTo Package the Hello Web 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 8.2 Reference Manual.

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 the 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. For more information, see Sun Java System Application Server Platform Edition 8.2 Developer’s Guide.

  1. Access http://localhost:4848/.

    • 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 Specify a package file to upload to the Application Server radio 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 OK.

    The application appears in the Web Applications list.

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

    The application's first page appears.

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

  4. Issue the following command to deploy the application:

    asadmin deploydir install-dir/samples/quickstart/hello2

    Note –

    Specify the full path to the hello2/ directory.

    If you installed the Application Server with the “Prompt for Administration User Name” option, also specify the option --user username, where username is the admin user name. You are prompted for the password.

    The following message appears: Command deploydir executed successfully.

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

Next Steps

You have completed the second section of the Quick Start Guide. See Using Command-Line Tools for more information on the command-line tools available in Application Server. See Where to Go Next for information on other resources for learning about Application Server.