Previous Contents Index Next |
Sun Java System Application Server Standard and Enterprise Edition 7 2004Q2 Developer's Guide

> ## Chapter 2
> Developing J2EE Applications

> This chapter gives guidelines for developing applications in Sun Java System Application Server 7. It includes the following sections:

> - Setting Up a Development Environment
> - Steps for Creating Components

> ##

> Setting Up a Development Environment

> 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, which are covered in the following sections:

> - Installing and Preparing the Server for Development
> - Development Tools

> ### Installing and Preparing the Server for Development

> For the mainstream installation, the following components are installed by default:

> - Sun Java System Application Server Core, including:
> - Sun Java™ System Message Queue
> - Administration interface
> - JDK
> - Sample Applications

> 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 “Classloaders” on page 74.
> - Enable dynamic reloading. For more information, see “Dynamic Reloading” on page 93.
> - Set up debugging. For more information, see Chapter 5, “Debugging J2EE Applications.”
> - Configure the Java™ Virtual Machine (JVM™) software. For more information, see the Sun Java System Application Server Administrator’s Guide.

> ### Development Tools

> The following general tools are provided with Sun Java System Application Server:

> - The asadmin Command
> - The Administration Interface

> The following development tools are provided with Sun Java System Application Server or downloadable from Sun:

> - Sun ONE Studio
> - Apache Ant
> - Migration Tools

> The following third-party tools may also be useful:

> - Profiling Tools

> #### 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 information about deployment using asadmin, see “The asadmin Command” on page 96. For general information about asadmin, see the Sun Java System Application Server Administrator’s Guide.

> #### The Administration Interface

> The Administration interface allows you to configure the server and perform both administrative and development tasks using a web browser. For information about deployment using the Administration interface, see “The Administration Interface” on page 97. For general information about the Administration interface, see the Sun Java System Application Server Administrator’s Guide.

> #### Sun ONE Studio

> Sun ONE Studio 5 is an IDE (integrated development environment) that allows you to create, assemble, deploy, and debug code in Sun Java System Application Server from a single, easy-to-use interface. Behind the scenes, a plug-in integrates Sun ONE Studio with Sun Java System Application Server. For more information about using Sun ONE Studio, see the Sun ONE Studio 5, Enterprise Edition Tutorial.

> #### Apache Ant

> You can use the automated assembly features available through Ant, a Java-based build tool available through the Apache Software Foundation:

> http://jakarta.apache.org/ant/

> 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.4.1 is provided with Sun Java System Application Server. 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 103.

> #### Migration Tools

> The following automated migration tools are downloadable from Sun:

> - The Sun Java System Migration Tool for Application Servers reassembles J2EE applications and modules developed on:
> - iPlanet Application Server 6.x
> - iPlanet Web Server 6.x
> - IBM’s Websphere Application Server 4.0
> - BEA Systems’ WebLogic Server 6.1
> - The Sun Java System Migration Toolbox helps you migrate applications developed on NetDynamics and Netscape Application Servers.

> For more information, see Sun Java System Application Server Migrating and Redeploying Server Applications.

> #### Profiling Tools

> You can use several profilers with Sun Java System Application Server, including HPROF, Optimizeit™, Wily Introscope®, and JProbe™. For more information, see “Profiling” on page 140.

> ##

> Steps for Creating Components

> Before creating J2EE applications and components, you should read “Best Practices for Designing J2EE Applications” on page 26.

> This section covers the basic steps for the following:

> - Creating Web Applications
> - Creating Enterprise JavaBeans
> - Creating ACC Clients
> - Creating Connectors
> - Creating Complete Applications

> ### Creating Web Applications

> To create a web application:

> 1. Create a directory for all the web application’s files. This is the web application’s document root.
> 2. Create any needed HTML files, image files, and other static content. Place these files in the document root directory or a subdirectory where they can be accessed by other parts of the application.
> 3. Create any needed JSP files.
> 4. Create any needed servlets.
> 5. Compile the servlets. You can also precompile the JSPs.
> 6. Create the WEB-INF directory and the other structural requirements of a web application.
> 7. Create the deployment descriptor files, web.xml and optionally sun-web.xml, in the WEB-INF directory. It is a good idea to verify the structure of these files as described in “The Deployment Descriptor Verifier” on page 83.
> 8. Package the web application in a WAR file. If you are using directory deployment, this is optional.
> 9. Deploy the web application by itself or include it in a J2EE application.

> For details about all these steps, see the Sun Java System Application Server Developer’s Guide to Web Applications.

> ### Creating Enterprise JavaBeans

> To create an EJB component:

> 1. Create a directory for all the EJB component’s files.
> 2. Decide on the type of EJB component you are creating:
> - Session
> - stateful
> - stateless
> - Entity
> - with bean-managed persistence
> - with container-managed persistence
> - Message-Driven
> 3. Write the code for the EJB component according to the EJB specification, including:
> - A local and/or remote home interface
> - A local and/or remote interface
> - An implementation class (for a message-driven bean, this is all you need)
> 4. Compile the interfaces and classes.
> 5. Create the META-INF directory and the other structural requirements of an EJB component.
> 6. Create the deployment descriptor files, ejb-jar.xml and sun-ejb-jar.xml, in the META-INF directory. If the EJB component is an entity bean with container-managed persistence, you must also create a .dbschema file and a sun-cmp-mapping.xml file. It is a good idea to verify the structure of these files as described in “The Deployment Descriptor Verifier” on page 83.
> 7. Package the EJB component in a JAR file. If you are using directory deployment, this is optional.
> 8. Deploy the EJB component by itself or include it in a J2EE application.

> For details about all these steps, see the Sun Java System Application Server Developer’s Guide to Enterprise JavaBeans Technology.

> ### Creating ACC Clients

> To create an ACC client:

> 1. Create a directory for all the client’s files.
> 2. Create the code for the client’s classes according to the Java 2 Platform Enterprise Edition Specification.
> 3. Compile the client’s interfaces and classes.
> 4. Create the META-INF directory and the other structural requirements of an ACC client.
> 5. Create the deployment descriptor files, application-client.xml and sun-application-client.xml, in the META-INF directory. It is a good idea to verify the structure of these files as described in “The Deployment Descriptor Verifier” on page 83.
> 6. Package the client in a JAR file. If the client communicates with one or more EJB components and you are using directory deployment, this is optional.
> 7. If the client communicates with one or more EJB components, package the client and EJB components together in an application, then deploy the application.
> 8. Prepare the client machine:
> 1. Create the ACC package JAR file.
> 2. Copy the ACC package JAR file to the client machine and unjar it.
> 3. Configure the sun-acc.xml and asenv.conf files.
> 4. Copy the client JAR to the client machine.
> 9. Execute the client.

> For details about all these steps, see the Sun Java System Application Server Developer’s Guide to Clients.

> ### Creating Connectors

> To create a connector:

> 1. Create a directory for all the connector’s files.
> 2. Create the code for the resource adapter classes (ConnectionFactory, Connection, and so on) according to the J2EE Connector Architecture Specification.
> 3. Compile the connector’s interfaces and classes.
> 4. Create one or more JAR files that contain all the connector’s classes.
> 5. Add any native libraries needed by the connector to the directory structure.
> 6. Create the META-INF directory and the other structural requirements of a connector. Here is an example of the overall directory structure:

> + MyConnector/ |--- readme.html |--- ra.jar |--- client.jar |--- win.dll |--- solaris.so '--+ META-INF/ |--- MANIFEST.MF |--- ra.xml '--- sun-ra.xml

> The ra.jar and client.jar files were created in Step 4. The win.dll and solaris.so files are native libraries that were added in Step 5.

> 7. Create the deployment descriptor files, ra.xml and sun-ra.xml, in the META-INF directory. Both are required. It is a good idea to verify the structure of these files as described in “The Deployment Descriptor Verifier” on page 83.
> 8. Create a RAR file from the directory structure described in Step 6. If you are using directory deployment, this is optional.
> 9. Deploy the connector by itself or include it in a J2EE application.

> For details about all these steps, see the Sun Java System J2EE CA Service Provider Implementation Administrator’s Guide.

> ### Creating Complete Applications

> To create a complete J2EE application:

> 1. Decide on the components (web applications, EJB components, and connectors) that the application will comprise.
> 2. Create a directory for all the application’s files, and create a the META-INF directory under it.
> 3. Create the components of the application and copy them into the application directory. Each component must be in an open subdirectory named by changing .jar, .war, or .rar to _jar, _war, or _rar, respectively.
> 4. Make sure the components call each other properly.
> 5. Create the deployment descriptor files, application.xml and optionally sun-application.xml, in the META-INF directory under the application directory. It is a good idea to verify the structure of these files as described in “The Deployment Descriptor Verifier” on page 83.
> 6. Package the application in an EAR file. If you are using directory deployment, this is optional.
> 7. Deploy the application.

> For details about all these steps, see Chapter 4, “Assembling and Deploying J2EE Applications.”

> Previous Contents Index Next

> Copyright 2004 Sun Microsystems, Inc. All rights reserved.