| Sun Java System Application Server |
This document provides common procedures to to build, deploy, and run the sample applications that come with the Sun Java System Application Server. For any additional application-specific steps, see the documentation for each application.
IMPORTANT: Be sure to read the following section to understand the variables and directories used in the samples documentation.
The samples documentation uses the following variables and directories. The documentation for each individual sample application specifies their value for that application:
install_dir is the directory where Application Server is installed.
app_dir is the sample application's base directory.
This directory contains all the application files.
For example, for the "simple" sample application, app_dir is
install_dir/samples/webapps/apps/simple/.
All application base directories contain at least:
build.xml file: The Ant build file.
/src sub-directory: Contains all the application source code.
/docs sub-directory: Contains the application-specific documentation.
The location of the domain root directory, domain_root_dir,
depends on which product you are using:
/var/opt/SUNWappserver/domains/
/var/opt/sun/appserver/domains/
install_dir/domains/
Within domain_root_dir, each domain is in a sub-directory,
domain_name, for example domain1.
So, for example, with Application Server Platform edition, the "normal" default domain is
install_dir/domains/domain1.
Every sample application comes with a pre-built application archive: either a web application archive (WAR) file or an enterprise application archive (EAR) file. You can skip building the application and deploy the pre-built archive file. Go to Deploying the Sample Application. Or, you can build the application yourself. If you have made any changes to the application source code or deployment descriptors, then you must build it yourself for those changes to take effect.
This section contains instructions for building a sample application using
asant, a command-line build tool provided with Application Server.
The asant tool is based on Ant,
developed by the Apache Software Foundation.
Prerequisite:
Ensure that install_dir/bin is in your path.
To build a sample application, follow these steps:
cd app_dir
asantThis command executes the default target
core and rebuilds the application
archive (WAR or EAR) file. asant clean
Now the application archive (WAR or EAR) is ready for deployment.
NOTE: You can verify the syntax and semantics of all deployment descriptors by running
asant verify from app_dir.
This may be useful if you have made changes to the deployment descriptor files.
To better understand the source code, you can generate Javadoc for the application. Javadocis a tool for generating API documentation in HTML format from doc comments in source code.
To generate Javadoc, use this command:
asant javadocs
This command generates a set of HTML files in the /javadocs sub-directory.
Start by opening app_dir/javadocs/index.html
in your web browser.
Note: Most samples support reploying without having to first undeploy.
In case of a problem, run asant undeploy and then redeploy the application.
This ensures that all modules are undeployed and the resources are disabled.
NOTE: This is the recommended deployment method for sample applications, because the Ant script
deploy target ensures that all neccessary resources (for example JDBC or JMS resources) are created.
Follow these steps to deploy an application using the asant command-line tool:
cd app_dir
asant deployThis deploys the application archive (WAR or EAR file).
Follow these steps to deploy using the browser-based Admin Console. In the basic procedure, the steps are similar for Enterprise applications and Web applications, except for the titles of the pages.
NOTE: If you deploy an application using the Admin Console instead of asant,
then you must create any required resources (for example, JDBC or JMS resources) before running the application.
When you use asant, they are automatically created for you.
install_dir/bin/asadmin start-domain domain1
http://hostname:port/asadminFor Application Server Platform Edition, the default port number is 4848. For Application Server Enterprise Edition, the default port number is 4849. If you are using a server on your local machine, you can use
localhost instead of
the host name.
app_dir.
Select the file then click "OK."
If you want, you can verify the application has been properly deployed and registered on the server. This step is optional. If you want to skip it, proceed to Running the Sample Application.
You can verify deployment with asadmin or the Admin Console.
Use the following command to list all applications deployed to a server instance:
asadmin list-components --user username --password password
If the application has been successfully deployed, its name will be listed.
Alternately, use Admin Console and navigate to Applications > Enterprise Applications or Applications > Web Applications, depending on whether the application is a web application or an enterprise application with EJBs. If the application has been deployed, Admin Console will display the application name.
To run a deployed application, load the following URL in your web browser:
http://hostname:port/contextRoot
If you are running the server on your local machine, you can use localhost instead
of the host name.
NOTE: Some of the sample applications are not browser-based applications that use a "standalone" Java client, and some sample applications are not even J2EE applications. In these cases, run the application from the command line. See the specific instructions for that application.
If you encounter problems when running the application, review the log files at
domain_root_dir/domain_name/logs/server.log
See Directories and Variables for an explanation of the
domain_root_dir and domain_name variables.
With Application Server Enterprise Edition, it may also be helpful to review node agent log files. Each node agent has its own log file located at:
node_agent_dir/node_agent_name/agent/logs/server.log
By default, node_agent_dir is install_dir/nodeagents.
Sometimes the node agent log instructs you to look at a server’s log to get a detailed message about a problem. The server logs are located at:
node_agent_dir/node_agent_name/server_name/logs/server.log
You can undeploy an application that has been deployed with
asant, the asadmin command, or Admin Console.
To undeploy the application with asant:
app_dir.
asant undeploy
To undeploy the application with asadmin:
app_dir.
asadmin undeploy --user user-name --password password --host hostname --port admin-port appnameIf the server is
localhost, you can omit the --host option.
If you are using the default administration port, you can omit the --port option.
To undeploy with Admin Console:
Copyright © 2006 Sun Microsystems, Inc. All rights reserved.