Document Information

Preface

Part I Introduction

1.  Overview

2.  Using the Tutorial Examples

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

The Resource Adapter

The Message-Driven Bean

The Web Application

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

 

Running the mailconnector Example

You can use either NetBeans IDE or Ant to build, package, deploy, and run the mailconnector example.

Before You Deploy the mailconnector Example

Before you deploy the mailconnector application, perform the following steps.

  1. Download mock-javamail-1.9.jar from http://download.java.net/maven/2/org/jvnet/mock-javamail/mock-javamail/1.9/.
  2. Copy this JAR file to the directory as-install/lib.
  3. Restart GlassFish Server.
  4. Open the GlassFish Server Administration Console in a web browser at http://localhost:4848.
  5. In the Administration Console, expand the Configurations node, then expand the server-config node.
  6. Select the Security node.
  7. Select the Default Principal to Role Mapping Enabled check box.
  8. Click Save.

To Build, Package, and Deploy the mailconnector Example Using NetBeans IDE

  1. From the File menu, choose Open Project.
  2. In the Open Project dialog, navigate to:
    tut-install/examples/connectors/mailconnector/
  3. Select the mailconnector-ra folder and click Open Project.
  4. In the Projects tab, right-click the mailconnector-ra project and select Build.

    This command builds the resource adapter. It also places identical files named mailconnector.rar and mailconnector.jar in the mailconnector directory.

  5. In the Projects tab, right-click the mailconnector-ra project and select Deploy.
  6. From the File menu, choose Open Project.
  7. In the Open Project dialog, navigate to:
    tut-install/examples/connectors/mailconnector/
  8. Select the mailconnector-ear folder.
  9. Select the Open Required Projects check box and click Open Project.
  10. In the Projects tab, right-click the mailconnector-ear project and select Build.
  11. In a terminal window, navigate to:
    tut-install/examples/connectors/mailconnector/mailconnector-ear/
  12. Enter the following command to create the resources and users:
    ant setup
  13. In NetBeans IDE, in the Projects tab, right-click the mailconnector-ear project and select Deploy.

To Build, Package, and Deploy the mailconnector Example Using Ant

  1. In a terminal window, go to:
    tut-install/examples/connectors/mailconnector/mailconnector-ear/
  2. Enter the following command:
    ant all

    This command builds and deploys the mailconnector-ra RAR file, sets up users and resources, then builds and deploys the mailconnector-ear EAR file. It also places identical files named mailconnector.rar and mailconnector.jar in the mailconnector directory.

To Run the mailconnector Example

  1. In a web browser, navigate to the following URL:
    http://localhost:8080/mailconnector-war/
  2. Log in with a user name of either user1, user2, user3, or user4. The password is the same as the user name.

    You can send messages and browse for the messages you sent. The messages you sent are available 30 seconds after you sent them.

    For example, you can log in as user1 and send a message to user4, then log in as user4 and query for messages. In the form for browsing messages, verify that the fields are correct, then click Browse.

    View the server log to follow the flow of the application. Most classes and methods specify logging information that makes the sequence of events easy to follow.

  3. Before you undeploy the application, in a terminal window, navigate to tut-install/examples/connectors/mailconnector/mailconnector-ear/ and enter the following command to remove the resources and users:
    ant takedown

    You cannot undeploy the resource adapter until you run this command.

Next Steps

When you clean the application, you can also remove the mailconnector.rar and mailconnector.jar files from the mailconnector directory.

Remove the mock-javamail-1.9.jar file from the as-install/lib directory if you might run any other applications that use the JavaMail API (for example, The async Example Application).