Sun ONE logo     Previous      Contents      Index      Next     
Sun ONE Application Server 7 Developer's Guide



Developing J2EE Applications

This module gives guidelines for developing applications in Sun ONE Application Server 7. It includes the following sections:

Setting Up a Development Environment

Setting up an environment for creating, assembling, deploying, and debugging your code involves installing the mainstream version of Sun ONE Application Server and making use of development tools, which are covered in the following sections:

Installing and Preparing the Server for Development

For bundled Solaris 9, Sun ONE Application Server installation is part of the operating system installation process. For more information, see the Solaris 9 Installation Guide.

For all other platforms, installing the mainstream (non-evaluation) version of Sun ONE Application Server is recommended.

For bundled Solaris 9 or the mainstream installation, the following components are installed by default:

  • Sun ONE Application Server Core, including:
    • Sun ONE Message Queue
    • Administration interface

  • JDK
  • Sun ONE Studio 4
  • Sample Applications

For more information, see the Sun ONE Application Server Installation Guide.

After you have installed Sun ONE 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".
  • Enable dynamic reloading. For more information, see "Dynamic Reloading".
  • Set up debugging. For more information, see "Debugging J2EE Applications."
  • Configure the JVM. For more information, see the Sun ONE Application Server Administrator's Guide.

Development Tools

The following general tools are provided with Sun ONE Application Server:

The following development tools are provided with Sun ONE 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 information about deployment using asadmin, see "The asadmin Command". For general information about asadmin, see the Sun ONE 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". For general information about the Administration interface, see the Sun ONE Application Server Administrator's Guide.

Sun ONE Studio

Sun ONE Studio 4 is an IDE (integrated development environment) that allows you to create, assemble, deploy, and debug code in Sun ONE Application Server from a single, easy-to-use interface. Behind the scenes, a plugin integrates Sun ONE Studio with Sun ONE Application Server. For more information about using Sun ONE Studio, see the Sun ONE Studio 4, 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 ONE Application Server (or with the operating system for bundled Solaris 9). Sun ONE Application Server also provides server-specific Ant tasks for deployment and administration with the sample applications. For more information about using Ant with Sun ONE Application Server, see "Apache Ant Assembly and Deployment Tool".

Migration Tools

The following automated migration tools are downloadable from Sun:

  • The Sun ONE 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 ONE Migration Toolbox helps you migrate applications developed on NetDynamics and Netscape Application Servers.

For more information, see Sun ONE Application Server Migrating and Redeploying Server Applications.

Profiling Tools

You can use several profilers with Sun ONE Application Server, including HPROF, Optimizeit™, Wily Introscope®, and JProbe™. For more information, see "Profiling".

Source Code Control Tools

The following source code control tools are supported through Sun ONE Studio 4:

  • Concurrent Versioning System (CVS) - built-in support in Community Edition
  • PVCS - predefined configuration
  • Visual Source Safe - predefined configuration
  • VCS - can be integrated using API
  • RCS - can be integrated using API
  • SCCS - can be integrated using API
  • Clearcase - can be integrated using API

For more information, see:

http://wwws.sun.com/software/sundev/jde/features/ce-features.html

Other Tools Supported Through Sun ONE Studio

For a list of other developer tools supported through Sun ONE Studio 4, see:

http://forte.sun.com/ffj/partnerprograms/partnerlist.html

Steps for Creating Components

Before creating J2EE applications and components, you should read "Best Practices for Designing J2EE Applications".

This section covers the basic steps for the following:

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".
  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 ONE 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".
  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 ONE 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".
  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 (asenv.bat on Windows) files.
    4. Copy the client JAR to the client machine.

  9. Execute the client.

For details about all these steps, see the Sun ONE 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:

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

  8. 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".
  9. Create a RAR file from the directory structure described in Step 6. If you are using directory deployment, this is optional.
  10. Deploy the connector by itself or include it in a J2EE application.

For details about all these steps, see the Sun ONE J2EE CA Service Provider Implementation Administrator's Guide.



Note

You can use the Sun ONE Connector Builder to make building connectors easier. For more information, see the Sun ONE Connector Builder Developer'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".
  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 "Assembling and Deploying J2EE Applications."


Previous      Contents      Index      Next     
Copyright 2002 Sun Microsystems, Inc. All rights reserved.