About the Author
Eric Jendrock leads Sun's Java EE Tutorial and Java WSIT Tutorial teams.
Jennifer Ball has documented JavaServer Faces technology, the Java2D API, deploytool, and JAXB.
Debbie Carson documents the Java EE, Java SE, and Java WSIT platforms.
Ian Evans documents the Java EE and Java Web Services platforms, and edits Java EE platform specifications.
Scott Fordin has written numerous articles and Sun guidebooks on Java, XML, and web service technologies.
Kim Haase documents the Java EE platform and Java Web Services, including Java Message Service (JMS), Java API for XML Registries (JAXR), and the SAAJ.
Excerpt. © Reprinted by permission. All rights reserved.
About This Tutorial
This tutorial is a guide to developing enterprise applications for the Java Platform, Enterprise Edition 5 (Java EE 5). Here we cover all the things you need to know to make the best use of this tutorial.
Who Should Use This Tutorial
This tutorial is intended for programmers who are interested in developing and deploying applications on the Sun Java System Application Server Platform Edition 9.
Before proceeding with this tutorial, you should have a good knowledge of the Java programming language. A good way to get to that point is to work through The Java&38482; Tutorial, Fourth Edition, Sharon Zakhour et al. (Addison-Wesley, 2006). You should also be familiar with the relational database features described in JDBC API Tutorial and Reference, Third Edition, Maydene Fisher et al. (Addison-Wesley, 2003).
How to Read This Tutorial
The Java EE 5 platform is quite large, and this tutorial reflects this. However, you don't have to digest everything in it at once. The tutorial has been divided into parts to help you navigate the content more easily.
This tutorial opens with an introductory chapter, which you should read before proceeding to any specific technology area. Chapter 1 covers the Java EE 5 platform architecture and APIs along with the Sun Java System Application Server Platform Edition 9.
When you have digested the basics, you can delve into one or more of the five main technology areas listed next. Because there are dependencies between some of the chapters, the following list contains a roadmap for navigating through the tutorial.
- The web-tier technology chapters cover the components used in developing the presentation layer of a Java EE 5 or stand-alone web application:
- Java Servlet
- JavaServer Pages (JSP)
- JavaServer Pages Standard Tag Library (JSTL)
- JavaServer Faces
- Web application internationalization and localization
- The web services technology chapters cover the APIs used in developing standard web services:
- The Java API for XML-based Web Services (JAX-WS)
- The Java API for XML Binding (JAXB)
- The Streaming API for XML (StAX)
- The SOAP with Attachments API for Java (SAAJ)
- The Java API for XML Registries (JAXR)
- The Enterprise JavaBeans (EJB) technology chapters cover the components used in developing the business logic of a application:
- Session beans
- Message-driven beans
- The Persistence technology chapters cover the Java Persistence API, which is used for accessing databases from Java EE applications:
- Introduction to the Java Persistence API
- Persistence in the Web Tier
- Persistence in the EJB Tier
- The Java Persistence Query Language
- The platform services chapters cover the system services used by all the Java EE 5 component technologies:
- Resource connections
- Java Message Service
- The Connector architecture
After you have become familiar with some of the technology areas, you are ready to tackle the case studies, which tie together several of the technologies discussed in the tutorial. The Coffee Break Application describes an application that uses the web application and web services APIs. The Duke's Bank Application describes an application that employs web application technologies, enterprise beans, and the Java Persistence API.
Finally, the appendix contains information about Java encoding schemes that may be helpful to the Java EE 5 application developer.
About the Examples
This section tells you everything you need to know to install, build, and run the examples.
The following software is required to run the examples.
The tutorial example source is contained in the tutorial bundle. If you are viewing this online, you need to click on the Download link at the top of any page.
After you have installed the tutorial bundle, the example source code is in the
‹INSTALL›/javaeetutorial5/examples/ directory, with subdirectories for each of the technologies discussed in the tutorial.
The Sun Java System Platform Application Server Platform Edition 9 is targeted as the build and runtime environment for the tutorial examples. To build, deploy, and run the examples, you need a copy of the Application Server and Java 2 Platform, Standard Edition 5.0 (J2SE 5.0). If you already have a copy of the J2SE SDK, you can download the Application Server from: http://java.sun.com/javaee/downloads/index.html
You can also download the Java EE 5 SDK--which contains the Application Server and the J2SE SDK--from the same site.
Application Server Installation Tips
In the Admin configuration pane of the Application Server installer:
- Select the Don't Prompt for Admin User Name radio button. This will save the user name and password so that you won't need to provide them when performing administrative operations with
asadmin. You will still have to provide the user name and password to log in to the Admin Console.
- Note the HTTP port at which the server is installed. This tutorial assumes that you are accepting the default port of 8080. If 8080 is in use during installation and the installer chooses another port or if you decide to change it yourself, you will need to update the common build properties file (described in the next section) and the configuration files for some of the tutorial examples to reflect the correct port.
In the Installation Options pane, check the Add Bin Directory to PATH checkbox so that Application Server scripts (
schemagen) override other installations.
The NetBeans integrated development environment (IDE) is a free, open-source IDE for developing Java applications, including enterprise applications. NetBeans 5.5 supports the Java EE 5 platform. You can build, package, deploy, and run the tutorial examples from within NetBeans 5.5, which you can download at http://www.netbeans.org/downloads/index.html. For information on creating enterprise applications in NetBeans 5.5, see http://www.netbeans.org/kb/55/index.html.
Ant is a Java technology-based build tool developed by the Apache Software Foundation (http://ant.apache.org), and is used to build, package, and deploy the tutorial examples. Ant is included with the Application Server. To use the ant command, add
‹JAVAEE_HOME›/lib/ant/bin to your PATH environment variable.
You need a registry server to run the examples discussed in Chapter 19. Instructions for obtaining and setting up a registry server are provided in Chapter 19.
Building the Examples
The tutorial examples are distributed with a configuration file for either NetBeans 5.5 or Ant. Directions for building the examples are provided in each chapter. Either NetBeans 5.5 or Ant may be used to build, package, deploy, and run the examples.
Building the Examples Using NetBeans 5.5
To run the tutorial examples in NetBeans 5.5, you must register your Application Server installation as a NetBeans Server Instance. Follow these instructions to register the Application Server in NetBeans 5.5.
- Select Tools→Server Manager to open the Server Manager dialog.
- Click Add Server.
- Under Server, select Sun Java System Application Server and click Next.
- Under Platform Location, enter the location of your Application Server installation.
- Select Register Local Default Domain and click Next.
- Under Admin Username and Admin Password, enter the admin name and password you specified while installing the Application Server.
- Click Finish.
Building the Examples on the Command-Line Using Ant
Build properties common to all the examples are specified in the
build.properties file in the
‹INSTALL›/javaeetutorial5/examples/bp-project/ directory. You must create this file before you can run the examples. We've included a sample file,
build.properties.sample, that you should rename to
build.properties and edit to reflect your environment. The tutorial examples use the Java BluePrints (http://java.sun.com/reference/blueprints/) build system and application layout structure.
To run the Ant scripts, you must set common build properties in the file
‹INSTALL› /javaeetutorial5/examples/bp-project/build.properties as follows:
- Set the javaee.home property to the location of your Application Server installation. The build process uses the
javaee.homeproperty to include the libraries in
‹JAVAEE_HOME›/lib/in the classpath. All examples that run on the Application Server include the Java EE library archive--
‹JAVAEE_HOME›/lib/javaee.jar--in the build classpath. Some examples use additional libraries in
‹JAVAEE_HOME›/lib/;the required libraries are enumerated in the individual technology chapters.
‹JAVAEE_HOME›refers to the directory where you have installed the Application Server.
- Note: On Windows, you must escape any backslashes in the
javaee.homeproperty with another backslash or use forward slashes as a path separator. So, if your Application Server installation is
C:\Sun\AppServer, you must set
javaee.home = C:\\Sun\\AppServer
- Note: On Windows, you must escape any backslashes in the
- Set the javaee.tutorial.home property to the location of your tutorial. This property is used for Ant deployment and undeployment.
- For example, on UNIX:
- If you did not use the default value (
admin) for the admin user, set the
admin.userproperty to the value you specified when you installed the Application Server.
- If you did not use port 8080, set the
domain.resources.portproperty to the value specified when you installed the Application Server.
- Set the admin user's password in the
admin-password.txtfile in the
‹INSTALL›/javaeetutorial5/examples/common/directory to the value you specified when you installed the Application Server. The format of this file is
AS_ADMIN_PASSWORD = password. For example:
AS_ADMIN_PASSWORD = mypassword
Do not install the tutorial to a location with spaces in the path.
Tutorial Example Directory Structure
To facilitate iterative development and keep application source separate from compiled files, the tutorial examples use the Java BluePrints application directory structure.
Each application module has the following structure:
build.xml: Ant build file
src/java: Java source files for the module
src/conf: configuration files for the module, with the exception of web applications
web: JSP and HTML pages, style sheets, tag files, and images
web/WEB-INF: configuration files for web applications
nbproject: NetBeans project files
Examples that have multiple application modules packaged into an enterprise application archive (or EAR) have submodule directories that use the following naming conventions:
‹EXAMPLE_NAME›-app-client: Application clients
‹EXAMPLE_NAME›-ejb: Enterprise bean JARs
‹EXAMPLE_NAME›-war: web applications
The Ant build files (
build.xml) distributed with the examples contain targets to create a
build subdirectory and to copy and compile files into that directory; a
dist subdirectory, which holds the packaged module file; and a
client-jar directory, which holds the retrieved application client JAR.
This tutorial includes the basic information that you need to deploy applications on and administer the Application Server.
See the Sun Java™ System Application Server Platform Edition 9 Developer's Guide at http://docs.sun.com/doc/819-3659 for information about developer features of the Application Server.
See the Sun Java™ System Application Server Platform Edition 9 Administration Guide at http://docs.sun.com/doc/819-3658 for information about administering the Application Server.
For information about the Java DB database included with the Application Server see the Apache web site at http://db.apache.org/derby.
Typographical conventions used in this tutorial are listed below.
- italic: Emphasis, titles, first occurrence of terms
monospace: URLs, code examples, file names, path names, tool names, application names, programming language keywords, tag, interface, class, method, and field names, properties
italic monospace: Variables in code, file paths, and URLs
italic monospace›: User-selected file path components
Menu selections indicated with the right-arrow character →, for example, First→ Second, should be interpreted as: select the First menu, then choose Second from the First submenu.
To send comments, broken link reports, errors, suggestions, and questions about this tutorial to the tutorial team, please use the feedback form at http://java.sun.com/javaee/5/docs/tutorial/information/sendusmail.html.