Sun Java System Application Server Platform Edition 8 Developer's Guide |
Chapter 1
Setting Up a Development EnvironmentThis chapter gives guidelines for setting up an application development environment in the Sun Java System Application Server. Setting up an environment for creating, assembling, deploying, and debugging your code involves installing the mainstream version of Sun Java System Application Server and making use of development tools. In addition, sample applications are available. These topics are covered in the following sections:
Installing and Preparing the Server for DevelopmentThe following components are included in the full installation. For more information, see the Sun Java System Application Server Installation Guide.
After you have installed Sun Java System Application Server, you can further optimize the server for development in these ways:
- Locate utility classes and libraries so they can be accessed by the proper classloaders. For more information, see “Using the System Classloader” on page 89 or “Using the Common Classloader” on page 90.
- Set up debugging. For more information, see Chapter 4, “Debugging J2EE Applications.”
- Configure the Java Virtual Machine (JVM) software. For more information, see the Sun Java System Application Server Administration Guide.
Development ToolsThe following general tools are provided with Sun Java System Application Server:
The following development tools are provided with Sun Java System Application Server or downloadable from Sun:
The following third-party tools may also be useful:
The asadmin Command
The asadmin command allows you to configure a local or remote server and perform both administrative and development tasks at the command line. For general information about asadmin, see the Sun Java System Application Server Administration Guide.
The Administration Console
The Administration Console lets you configure the server and perform both administrative and development tasks using a web browser. For general information about the Administration Console, see the Sun Java System Application Server Administration Guide.
Apache Ant
You can use the automated assembly features available through Ant, a Java-based build tool available through the Apache Software Foundation:
Ant is a java-based build tool that is extended using Java classes. Instead of using shell commands, the configuration files are XML-based, calling out a target tree where tasks get executed. Each task is run by an object that implements a particular task interface.
Apache Ant 1.5.4 is provided with Sun Java System Application Server, and can be launched from the bin directory using the command asant. Sun Java System Application Server also provides server-specific Ant tasks for deployment and administration with the sample applications. For more information about using Ant with Sun Java System Application Server, see “Apache Ant Assembly and Deployment Tool” on page 115.
deploytool
You can use the deploytool, provided with Sun Java System Application Server, to assemble J2EE applications and modules, configure deployment parameters, perform simple static checks, and deploy the final result. For more information about using the deploytool, see the J2EE 1.4 Tutorial:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
Migration Tools
The following automated migration tools are downloadable from Sun:
For more information, see Sun Java System Application Server Migrating and Redeploying Server Applications.
Debugging Tools
You can use several debuggers with the Sun Java System Application Server. For more information, see Chapter 4, “Debugging J2EE Applications.”
Profiling Tools
You can use several profilers with the Sun Java System Application Server. For more information, see “Profiling” on page 139.
Sample ApplicationsSample applications that you can examine and deploy are included with the full installation of the Sun Java System Application Server. You can also download these samples separately if you installed the Sun Java System Application Server without them initially.
If installed with the Sun Java System Application Server, the samples are in the install_dir/samples directory. The samples are organized in categories such as ejb, jdbc, connectors, i18n, and so on. Each sample category is further divided into subcategories. For example, under the ejb category are stateless, stateful, security, mdb, bmp, and cmp subcategories.
Most Sun Java System Application Server samples have the following directory structure:
- The docs directory contains instructions for how to use the sample.
- The src directory contains:
- Source code
- The build.xml file, which defines asant targets for the sample (see Apache Ant)
- Deployment descriptors
- The build, assemble, and javadocs directories are generated as a result of targets specified in the build.xml file.
The install_dir/samples/common.xml file defines properties common to all sample applications and implements targets needed to compile, assemble, deploy and undeploy sample applications. In most sample applications, the build.xml file includes common.xml.
Note
Before using the samples under install_dir/samples/webservices, make sure to copy the Java XML Pack JAR files into the jre/lib/endorsed directory to override the files bundled with the JDK.
The following figure shows the structure of the helloworld sample:
Figure 1-1 The helloworld sample
After you deploy the sample in Sun Java System Application Server, you can invoke it using the following URL:
http://server:port/helloworld
For a detailed description of the sample and how to deploy and run it, see the associated documentation at:
install_dir/samples/ejb/stateless/simple/docs/index.html