Document Information

Preface

Part I Introduction

1.  Overview

2.  Using the Tutorial Examples

Starting and Stopping the GlassFish Server

To Start the GlassFish Server Using NetBeans IDE

Starting the Administration Console

To Start the Administration Console Using NetBeans IDE

Starting and Stopping the Java DB Server

To Start the Database Server Using NetBeans IDE

Building the Examples

Tutorial Example Directory Structure

Getting the Latest Updates to the Tutorial

To Update the Tutorial through the Update Center

Debugging Java EE Applications

Using the Server Log

To Use the Administration Console Log Viewer

Using a Debugger

To Debug an Application Using a Debugger

Part II The Web Tier

3.  Getting Started with Web Applications

4.  JavaServer Faces Technology

5.  Introduction to Facelets

6.  Expression Language

7.  Using JavaServer Faces Technology in Web Pages

8.  Using Converters, Listeners, and Validators

9.  Developing with JavaServer Faces Technology

10.  JavaServer Faces Technology: Advanced Concepts

11.  Using Ajax with JavaServer Faces Technology

12.  Composite Components: Advanced Topics and Example

13.  Creating Custom UI Components and Other Custom Objects

14.  Configuring JavaServer Faces Applications

15.  Java Servlet Technology

16.  Uploading Files with Java Servlet Technology

17.  Internationalizing and Localizing Web Applications

Part III Web Services

18.  Introduction to Web Services

19.  Building Web Services with JAX-WS

20.  Building RESTful Web Services with JAX-RS

21.  JAX-RS: Advanced Topics and Example

Part IV Enterprise Beans

22.  Enterprise Beans

23.  Getting Started with Enterprise Beans

24.  Running the Enterprise Bean Examples

25.  A Message-Driven Bean Example

26.  Using the Embedded Enterprise Bean Container

27.  Using Asynchronous Method Invocation in Session Beans

Part V Contexts and Dependency Injection for the Java EE Platform

28.  Introduction to Contexts and Dependency Injection for the Java EE Platform

29.  Running the Basic Contexts and Dependency Injection Examples

30.  Contexts and Dependency Injection for the Java EE Platform: Advanced Topics

31.  Running the Advanced Contexts and Dependency Injection Examples

Part VI Persistence

32.  Introduction to the Java Persistence API

33.  Running the Persistence Examples

34.  The Java Persistence Query Language

35.  Using the Criteria API to Create Queries

36.  Creating and Using String-Based Criteria Queries

37.  Controlling Concurrent Access to Entity Data with Locking

38.  Using a Second-Level Cache with Java Persistence API Applications

Part VII Security

39.  Introduction to Security in the Java EE Platform

40.  Getting Started Securing Web Applications

41.  Getting Started Securing Enterprise Applications

42.  Java EE Security: Advanced Topics

Part VIII Java EE Supporting Technologies

43.  Introduction to Java EE Supporting Technologies

44.  Transactions

45.  Resources and Resource Adapters

46.  The Resource Adapter Example

47.  Java Message Service Concepts

48.  Java Message Service Examples

49.  Bean Validation: Advanced Topics

50.  Using Java EE Interceptors

Part IX Case Studies

51.  Duke's Bookstore Case Study Example

52.  Duke's Tutoring Case Study Example

53.  Duke's Forest Case Study Example

Index

 

Required Software

The following software is required to run the examples:

Java Platform, Standard Edition

To build, deploy, and run the examples, you need a copy of the Java Platform, Standard Edition 6.0 Development Kit (JDK 6) or the Java Platform, Standard Edition 7.0 Development Kit (JDK 7). You can download the JDK 6 or JDK 7 software from http://www.oracle.com/technetwork/java/javase/downloads/index.html.

Download the current JDK update that does not include any other software, such as NetBeans IDE or the Java EE SDK.

Java EE 6 Software Development Kit

GlassFish Server Open Source Edition 3.1.2 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 GlassFish Server and, optionally, NetBeans IDE. To obtain the GlassFish Server, you must install the Java EE 6 Software Development Kit (SDK), which you can download from http://www.oracle.com/technetwork/java/javaee/downloads/index.html. Make sure you download the Java EE 6 SDK, not the Java EE 6 Web Profile SDK.

SDK Installation Tips

During the installation of the SDK, do the following:

  • Allow the installer to download and configure the Update Tool. If you access the Internet through a firewall, provide the proxy host and port.

  • Configure the GlassFish Server administration user name as admin, and specify no password. This is the default setting.

  • Accept the default port values for the Admin Port (4848) and the HTTP Port (8080).

  • Do not select the check box to create an operating system service for the domain.

You can leave the check box to start the domain after creation selected if you wish, but this is not required.

This tutorial refers to as-install-parent, the directory where you install the GlassFish Server. For example, the default installation directory on Microsoft Windows is C:\glassfish3, so as-install-parent is C:\glassfish3. The GlassFish Server itself is installed in as-install, the glassfish directory under as-install-parent. So on Microsoft Windows, as-install is C:\glassfish3\glassfish.

After you install the GlassFish Server, add the following directories to your PATH to avoid having to specify the full path when you use commands:

as-install-parent/bin
as-install/bin

Java EE 6 Tutorial Component

The tutorial example source is contained in the tutorial component. To obtain the tutorial component, use the Update Tool.

To Obtain the Tutorial Component Using the Update Tool

  1. Start the Update Tool by doing one of the following:
    • From the command line, type the command updatetool.
    • On a Windows system, from the Start menu, select All Programs, then select Java EE 6 SDK, then select Start Update Tool.
  2. Expand the Java EE 6 SDK node.
  3. Select the Available Updates node.
  4. From the list, select the Java EE 6 Tutorial check box.
  5. Click Install.
  6. Accept the license agreement.

    After installation, the Java EE 6 Tutorial appears in the list of installed components. The tool is installed in the as-install/docs/javaee-tutorial directory. This directory contains two subdirectories: docs and examples. The examples directory contains subdirectories for each of the technologies discussed in the tutorial.

Next Steps

Updates to the Java EE 6 Tutorial are published periodically. For details on obtaining these updates, see Getting the Latest Updates to the Tutorial.

NetBeans IDE

The NetBeans integrated development environment (IDE) is a free, open-source IDE for developing Java applications, including enterprise applications. NetBeans IDE supports the Java EE platform. You can build, package, deploy, and run the tutorial examples from within NetBeans IDE.

To run the tutorial examples, you need the latest version of NetBeans IDE. You can download NetBeans IDE from http://www.netbeans.org/downloads/index.html. Make sure that you download the Java EE bundle.

To Install NetBeans IDE without GlassFish Server

When you install NetBeans IDE, do not install the version of GlassFish Server that comes with NetBeans IDE. To skip the installation of GlassFish Server, follow these steps.

  1. On the first page of the NetBeans IDE Installer wizard, deselect the check box for GlassFish Server and click OK.
  2. Accept both the License Agreement and the Junit License Agreement.

    A few of the tutorial examples use the Junit library, so you should install it.

  3. Continue with the installation of NetBeans IDE.

To Add GlassFish Server as a Server in NetBeans IDE

To run the tutorial examples in NetBeans IDE, you must add your GlassFish Server as a server in NetBeans IDE. Follow these instructions to add the GlassFish Server to NetBeans IDE.

  1. From the Tools menu, select Servers.

    The Servers wizard opens.

  2. Click Add Server.
  3. Under Choose Server, select GlassFish Server 3+ and click Next.
  4. Under Server Location, browse to the location of the Java EE 6 SDK and click Next.
  5. Under Domain Location, select Register Local Domain.
  6. Click Finish.

Apache Ant

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. To run the tutorial examples, you need Ant 1.7.1 or higher. If you do not already have Ant, you can install it from the Update Tool that is part of the GlassFish Server.

To Obtain Apache Ant

  1. Start the Update Tool.
    • From the command line, type the command updatetool.
    • On a Windows system, from the Start menu, select All Programs, then select Java EE 6 SDK, then select Start Update Tool.
  2. Expand the Java EE 6 SDK node.
  3. Select the Available Add-ons node.
  4. From the list, select the Apache Ant Build Tool check box.
  5. Click Install.
  6. Accept the license agreement.

    After installation, Apache Ant appears in the list of installed components. The tool is installed in the as-install-parent/ant directory.

Next Steps

To use the ant command, add as-install-parent/ant/bin to your PATH environment variable.