Académique Documents
Professionnel Documents
Culture Documents
D53942GC10
Edition 1.0
January 2009
D57568
Authors Copyright © 2009, Oracle. All rights reserved.
Gary Williams This document contains proprietary information and is protected by copyright and
other intellectual property laws. You may copy and print this document solely for your
own use in an Oracle training course. The document may not be modified or altered in
Technical Contributors any way. Except where your use constitutes "fair use" under copyright law, you may
and Reviewers not use, share, download, upload, copy, print, display, perform, reproduce, publish,
license, post, transmit, or distribute this document in whole or in part without the
Ken Cooper express authorization of Oracle.
Joe Greenwald
The information contained in this document is subject to change without notice. If you
Taj-ul Islam find any problems in the document, please report them in writing to: Oracle University,
500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
Pete Laseau warranted to be error-free.
Adam Leftik
Restricted Rights Notice
Mike Lehmann
Jacobo Marcos If this documentation is delivered to the United States Government or anyone using
the documentation on behalf of the United States Government, the following notice is
Glenn Maslen applicable:
Duncan Mills U.S. GOVERNMENT RIGHTS
Lynn Munsinger The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or
disclose these training materials are restricted by the terms of the applicable Oracle
Nagavalli Pataballa license agreement and/or the applicable U.S. Government contract.
Holger Rasmussen
Trademark Notice
Anand Sidgiddi
Glenn Stokol Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other
names may be trademarks of their respective owners.
Vasily Strelnikov
Bonnie Vaughan
Editors
Aju Kumar
Amitha Narayan
Graphic Designer
Priya Saxena
Publishers
Sujatha Nagendra
Joseph Fernandez
Contents
1 Introduction
Objectives 1-2
Course Objectives 1-3
Course Agenda 1-4
Fundamentals of Java EE Technology 1-9
Designing Java EE Applications 1-10
Developing a Web Application Using Servlets 1-11
Developing a Web Application Using JavaServer Pages 1-12
Accessing Resources with JNDI and Dependency Injection 1-13
Developing the Business Logic with Session Beans 1-14
Developing the Persistence Layer with JPA Entities 1-15
Manipulating JPA Entities with the EntityManager API 1-16
Developing the Business Logic with Web Services 1-17
Developing the Web Interface Using JavaServer Faces 1-18
Planning Navigation and Page Flow 1-19
Handling Application Events 1-20
Asynchronous Communication with Message-Driven Beans 1-21
Managing Transactions with Session and Message-Driven Beans 1-22
Securing Java EE Applications with JAAS 1-23
Packaging and Deploying Java EE Applications 1-24
Troubleshooting Java EE Applications 1-25
Summary 1-26
iii
Types of Enterprise JavaBeans 3.0 2-17
Enterprise JavaBeans 3.0 Component Architecture 2-18
Java Persistence API (JPA) 2-19
Quiz 2-21
Web Services 2-22
Java EE Web Services Architecture 2-23
Client-Tier Components 2-25
Java EE Web-Tier Components 2-26
Java EE Web Application Architecture 2-28
What Is a Servlet? 2-29
What Is a JavaServer Page? 2-30
What Is JavaServer Faces? 2-31
Web-Tier Components: Summary 2-32
Java EE Applications 2-33
Packaging Java EE Applications 2-34
Packaging Java EE Application Components 2-35
Security in Java EE Applications 2-36
Using Deployment Descriptors for Declarative Security 2-37
Quiz 2-38
Java EE Server 2-39
Oracle WebLogic Server 10.3 2-41
WebLogic Server Domain 2-42
WebLogic Server Servers 2-44
Administration Server 2-45
Managed Server 2-46
WebLogic Server Machines 2-47
JDeveloper and Java EE 2-48
Oracle JDeveloper 11g Environment 2-49
Oracle JDeveloper 11g Visual Design Tools 2-50
Summary 2-51
Practice: Overview 2-52
iv
The View 3-10
The Controller 3-11
Designing a Java EE Application 3-12
Quiz 3-13
Struts: Overview 3-14
Struts Components 3-15
Struts Architecture 3-16
Struts Page Flow Design 3-17
JSF and Struts 3-19
Implementing the User Interface with JSF and Core Java EE Patterns 3-20
Selecting a Persistence Strategy 3-21
Quiz 3-22
What Is a Data Source? 3-23
What Is a Connection Pool? 3-24
Benefits of Data Sources Plus Connection Pools 3-25
JDBC Data Source Architecture 3-26
Data Source Architecture: Connecting 3-27
Creating a Data Source in WebLogic Server 3-28
Summary 3-30
Practice: Overview 3-31
v
Error Handling 4-20
Debugging a Servlet 4-21
JDeveloper Environment 4-22
Servlet Mapping 4-23
Servlet Mapping in JDeveloper 4-24
Invoking a Servlet 4-25
Specifying Java EE Web Module Settings 4-26
Summary 4-27
Practice: Overview 4-28
vi
Tag Library Descriptor 5-38
Implementing Simple Tags 5-39
JSP Expression Language 5-40
Expression Language Implicit Objects 5-41
JDeveloper and JSPs 5-42
Summary 5-43
Practice: Overview 5-44
vii
Life Cycle of a Stateful Session Bean 7-12
Passivation and Activation Concepts 7-14
Creating a Stateful Session Bean 7-15
Defining the Stateful Session Bean 7-16
Analyzing the Remote and Local Interfaces 7-17
Creating a Test Client for the SFSB 7-18
Calling a Stateless Bean from a Stateful Bean by Implementing DI 7-19
Interceptor Methods and Classes 7-20
Interceptor Method 7-21
Interceptor Classes 7-22
Summary 7-23
Practice: Overview 7-24
viii
Accessing an EntityManager Instance in an Application 9-7
Creating a Container-Managed EntityManager Instance 9-8
Creating an Application-Managed EntityManager Instance 9-9
Specifying Database Operations with the EntityManager API 9-10
Commonly Used Methods in the EntityManager Interface 9-11
Quiz 9-13
Inserting New Data 9-14
Deleting Data 9-15
Updating and Synchronizing the Entity with the Database 9-16
Updating Data 9-17
Finding an Entity by Primary Key 9-18
Quiz 9-19
What Is JPA Query API? 9-20
Retrieving Entities by Using the Query API 9-21
Writing a Basic JPQL Statement 9-22
Creating Named Queries 9-23
Writing Dynamic Queries 9-24
Summary 9-25
Practice: Overview 9-26
ix
Creating the WSDL Document 10-23
Modifying the WSDL Document 10-25
Creating the Web Service by Using Oracle JDeveloper 11g 10-26
Implementing the Web Service Logic 10-27
Summary 10-28
Practice: Overview 10-29
x
Summary 11-39
Practice: Overview 11-40
xi
Event and Listener Execution Order 13-12
Validation in the JSF Life Cycle 13-13
Creating Custom Exception Handlers 13-15
Registering an Exception Handler 13-16
Changing Life Cycle Exception Reporting 13-17
JavaServer Faces Validators 13-18
Creating Backing Bean Validation in JDeveloper 13-19
Backing Bean Validator: Code Example 13-20
Input Validation 13-21
Summary 13-22
Practice: Overview 13-23
xii
Types of Transactions 15-5
Transaction Management 15-7
Two-Phase Commit Protocol 15-8
Successful Two-Phase Commit 15-9
Unsuccessful Two-Phase Commit 15-10
Quiz 15-11
Java Transaction API (JTA) 15-12
EJB Transaction Model 15-13
Managing Transactions with EJBs 15-14
Types of Transaction Management 15-16
Container-Managed Transactions 15-17
Transaction Attribute: REQUIRED 15-18
Transaction Attribute: SUPPORTS 15-19
Transaction Attribute: MANDATORY 15-20
Transaction Attribute: NEVER 15-21
Transaction Attribute: REQUIRES_NEW 15-22
Transaction Attribute: NOT_SUPPORTED 15-23
Quiz 15-24
CMT: setRollbackOnly() 15-25
Container-Managed Transaction: Example 15-26
Java Transaction API (JTA) 15-27
JTA: UserTransaction Interface 15-29
Bean-Managed Transactions 15-30
Bean-Managed Transaction: Example 15-31
BMT Demarcation: Restrictions 15-32
Enlisting Database Resources 15-33
Summary 15-34
Practice: Overview 15-35
xiii
Configuring New Users in WebLogic Server 16-14
Adding Users to Groups 16-16
Logical Roles 16-17
Quiz 16-19
Configuring Security 16-20
Determining Protected Resources 16-21
Defining the Logical Roles 16-22
Defining and Using Logical Roles in Web Applications (web.xml) 16-23
Defining and Using Logical Roles in EJBs (ejb-jar.xml) 16-24
Mapping Logical Roles to Users and Groups 16-25
Setup Authentication 16-26
Authentication Examples 16-27
Setting Access Control with JDeveloper 16-28
Creating Web Application Security Roles 16-29
Web Application Login Authentication 16-30
Web Application Authorization 16-31
EJB Security Roles 16-32
Security Annotation: Example 16-33
Summary 16-34
Practice: Overview 16-35
xiv
Deploying with the Oracle WebLogic Server Console 17-23
Deploying with Oracle JDeveloper 17-24
What Is Ant? 17-25
Ant Build Files 17-26
A Sample build.xml File 17-27
Creating a JAR File by Using Ant Task 17-28
Creating a WAR File by Using Ant Task 17-29
Creating an EAR File by Using Ant Task 17-30
Deploying an Application by Using Ant Task 17-31
Packaging Best Practices for Production Environments 17-32
Summary 17-33
18 Troubleshooting
Objectives 18-2
Troubleshooting Basics 18-3
Diagnosing the Problem 18-4
Requesting Help 18-5
Creating Test Cases 18-6
Java Logging 18-7
Configuring Java Logging 18-8
Sending Logger Output to a File 18-9
Turning on Diagnostics in JDeveloper 18-10
Sample Java Clients 18-11
Sample Client for Web Service 18-12
Tools and Utilities 18-13
Identifying Search Paths with FileMon 18-14
Testing Java Code with JUnit 18-15
Analyzing HTTP Requests 18-16
Debugging with JDeveloper 18-17
Summary 18-18
xv
Printing Layout Panel Content B-9
Creating Collapsible Panes with the Panel Splitter Component B-10
Creating Collapsible Panes with the Panel Accordion B-11
Panel Accordion Overflow B-13
Setting Panel Accordion Properties B-14
Arranging Items in Columns or Grids B-15
Creating Stacked Tabs B-17
Hiding and Displaying Groups of Content B-18
Arranging Items Horizontally or Vertically, with Scrollbars B-20
Displaying Table Menus, Toolbars, and Status Bars B-22
Creating Titled Sections and Subsections B-24
Grouping Semantically Related Components B-25
Displaying a Bulleted List B-26
Displaying Items in a Content Container Offset by Color B-27
Arranging Items Around a Central Area B-28
Using ADF Faces Skins B-30
Using Dynamic Page Layout B-31
Using Expression Language to Conditionally Display Components B-32
Characteristics of Partial Page Rendering (PPR) B-33
Enabling PPR Declaratively B-34
Native PPR Example B-36
Declarative PPR Example B-37
Enabling PPR Programmatically B-39
Conforming to PPR Guidelines B-40
Summary B-41
Index
xvi