13 - [1 Java Platform Enterprise Edition The Java EE Tutorial Release 7 E39031-01 September 2014 Java Platform Enterprise Edition The Java EE Tutorial

13 - [1 Java Platform Enterprise Edition The Java EE...

This preview shows page 1 out of 980 pages.

You've reached the end of your free preview.

Want to read all 980 pages?

Unformatted text preview: [1] Java Platform, Enterprise Edition The Java EE Tutorial Release 7 E39031-01 September 2014 Java Platform, Enterprise Edition The Java EE Tutorial, Release 7 E39031-01 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Primary Author: Eric Jendrock, Ricardo Cervera-Navarro, Ian Evans, Kim Haase, William Markito Contributing Author: Contributor: This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government. This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. This software or hardware and documentation may provide access to or information on content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services. Contents Preface ........................................................................................................................................................... xxxix Audience................................................................................................................................................. xxxix Documentation Accessibility ............................................................................................................... xxxix Before You Read This Book........................................................................................................................ xl Related Documentation .............................................................................................................................. xl Conventions ................................................................................................................................................. xl Default Paths and File Names ................................................................................................................... xl Part I Introduction 1 Overview 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.3.1 1.3.3.2 1.3.3.3 1.3.3.4 1.3.3.5 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.6 1.7 1.7.1 Java EE 7 Platform Highlights................................................................................................... 1-2 Java EE Application Model ....................................................................................................... 1-2 Distributed Multitiered Applications ...................................................................................... 1-3 Security.................................................................................................................................. 1-4 Java EE Components ........................................................................................................... 1-4 Java EE Clients ..................................................................................................................... 1-5 Web Clients.................................................................................................................... 1-5 Application Clients....................................................................................................... 1-5 Applets ........................................................................................................................... 1-5 The JavaBeans Component Architecture .................................................................. 1-6 Java EE Server Communications................................................................................ 1-6 Web Components ................................................................................................................ 1-6 Business Components ......................................................................................................... 1-7 Enterprise Information System Tier.................................................................................. 1-8 Java EE Containers...................................................................................................................... 1-8 Container Services ............................................................................................................... 1-9 Container Types ................................................................................................................... 1-9 Web Services Support.............................................................................................................. 1-10 XML .................................................................................................................................... 1-11 SOAP Transport Protocol ................................................................................................ 1-11 WSDL Standard Format................................................................................................... 1-11 Java EE Application Assembly and Deployment................................................................ 1-12 Java EE 7 APIs .......................................................................................................................... 1-12 Enterprise JavaBeans Technology .................................................................................. 1-15 iii 1.7.2 Java Servlet Technology................................................................................................... 1.7.3 JavaServer Faces Technology .......................................................................................... 1.7.4 JavaServer Pages Technology ......................................................................................... 1.7.5 JavaServer Pages Standard Tag Library ........................................................................ 1.7.6 Java Persistence API ......................................................................................................... 1.7.7 Java Transaction API ........................................................................................................ 1.7.8 Java API for RESTful Web Services................................................................................ 1.7.9 Managed Beans ................................................................................................................. 1.7.10 Contexts and Dependency Injection for Java EE.......................................................... 1.7.11 Dependency Injection for Java ........................................................................................ 1.7.12 Bean Validation ................................................................................................................. 1.7.13 Java Message Service API................................................................................................ 1.7.14 Java EE Connector Architecture ..................................................................................... 1.7.15 JavaMail API...................................................................................................................... 1.7.16 Java Authorization Contract for Containers................................................................. 1.7.17 Java Authentication Service Provider Interface for Containers................................. 1.7.18 Java API for WebSocket ................................................................................................... 1.7.19 Java API for JSON Processing......................................................................................... 1.7.20 Concurrency Utilities for Java EE................................................................................... 1.7.21 Batch Applications for the Java Platform ...................................................................... 1.8 Java EE 7 APIs in the Java Platform, Standard Edition 7 ................................................... 1.8.1 Java Database Connectivity API..................................................................................... 1.8.2 Java Naming and Directory Interface API .................................................................... 1.8.3 JavaBeans Activation Framework .................................................................................. 1.8.4 Java API for XML Processing.......................................................................................... 1.8.5 Java Architecture for XML Binding ............................................................................... 1.8.6 Java API for XML Web Services ..................................................................................... 1.8.7 SOAP with Attachments API for Java ........................................................................... 1.8.8 Java Authentication and Authorization Service........................................................... 1.8.9 Common Annotations for the Java Platform ................................................................ 1.9 GlassFish Server Tools ............................................................................................................ 1-15 1-16 1-16 1-17 1-17 1-17 1-17 1-17 1-18 1-18 1-18 1-18 1-18 1-19 1-19 1-19 1-19 1-20 1-20 1-20 1-20 1-20 1-21 1-21 1-21 1-21 1-22 1-22 1-22 1-22 1-22 2 Using the Tutorial Examples 2.1 Required Software ...................................................................................................................... 2-1 2.1.1 Java Platform, Standard Edition ........................................................................................ 2-1 2.1.2 Java EE 7 Software Development Kit................................................................................ 2-1 2.1.2.1 SDK Installation Tips ................................................................................................... 2-2 2.1.3 Java EE 7 Tutorial Component........................................................................................... 2-2 2.1.4 NetBeans IDE ....................................................................................................................... 2-2 2.1.4.1 To Install NetBeans IDE without GlassFish Server ................................................. 2-2 2.1.4.2 To Add GlassFish Server as a Server Using NetBeans IDE.................................... 2-3 2.1.5 Apache Maven ..................................................................................................................... 2-3 2.2 Starting and Stopping GlassFish Server .................................................................................. 2-3 2.2.1 To Start GlassFish Server Using NetBeans IDE............................................................... 2-3 2.2.2 To Stop GlassFish Server Using NetBeans IDE ............................................................... 2-3 2.2.3 To Start GlassFish Server Using the Command Line ..................................................... 2-3 2.2.4 To Stop GlassFish Server Using the Command Line ..................................................... 2-4 iv 2.3 2.3.1 2.4 2.4.1 2.5 2.6 2.7 2.7.1 2.7.1.1 2.7.1.2 2.8 2.8.1 2.8.2 2.9 2.9.1 2.9.1.1 2.9.2 2.9.2.1 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 ..................................................................................... Java EE 7 Maven Archetypes in the Tutorial .......................................................................... Installing the Tutorial Archetypes .................................................................................... Installing the Tutorial Archetypes Using NetBeans IDE ........................................ Installing the Tutorial Archetypes Using Maven .................................................... Getting the Latest Updates to the Tutorial.............................................................................. To Update the Tutorial Using NetBeans IDE .................................................................. To Update the Tutorial Using the Command Line......................................................... 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 ........................................................... 2-4 2-4 2-4 2-5 2-5 2-5 2-6 2-6 2-6 2-6 2-6 2-6 2-6 2-7 2-7 2-7 2-7 2-7 Part II Platform Basics 3 Resource Creation 3.1 3.2 3.3 Resources and JNDI Naming .................................................................................................... 3-1 DataSource Objects and Connection Pools ............................................................................. 3-2 Creating Resources Administratively ...................................................................................... 3-2 4 Injection 4.1 4.2 4.3 Resource Injection ....................................................................................................................... 4-1 Dependency Injection................................................................................................................. 4-2 The Main Differences between Resource Injection and Dependency Injection................. 4-2 5 Packaging 5.1 5.2 5.2.1 5.2.2 5.3 5.4 Part III Packaging Applications ............................................................................................................. Packaging Enterprise Beans ...................................................................................................... Packaging Enterprise Beans in EJB JAR Modules........................................................... Packaging Enterprise Beans in WAR Modules ............................................................... Packaging Web Archives ........................................................................................................... Packaging Resource Adapter Archives ................................................................................... 5-1 5-2 5-3 5-3 5-4 5-5 The Web Tier 6 Getting Started with Web Applications 6.1 6.2 6.3 Web Applications........................................................................................................................ 6-1 Web Application Lifecycle......................................................................................................... 6-2 A Web Module That Uses JavaServer Faces Technology: The hello1 Example................. 6-3 v 6.3.1 To View the hello1 Web Module Using NetBeans IDE.................................................. 6-3 6.3.1.1 Introduction to Scopes ................................................................................................. 6-6 6.3.2 Packaging and Deploying the hello1 Web Module ........................................................ 6-6 6.3.2.1 To Build and Package the hello1 Web Module Using NetBeans IDE................... 6-6 6.3.2.2 To Build and Package the hello1 Web Module Using Maven ............................... 6-7 6.3.3 Viewing Deployed Web Modules ..................................................................................... 6-7 6.3.3.1 To View Deployed Web Modules Using the Administration Console ................ 6-7 6.3.3.2 To View Deployed Web Modules Using the asadmin Command ........................ 6-7 6.3.3.3 To View Deployed Web Modules Using NetBeans IDE......................................... 6-7 6.3.4 Running the Deployed hello1 Web Module .................................................................... 6-7 6.3.4.1 Dynamic Reloading of Deployed Modules .............................................................. 6-8 6.3.5 Undeploying the hello1 Web Module .............................................................................. 6-8 6.3.5.1 To Undeploy the hello1 Web Module Using NetBeans IDE .................................. 6-8 6.3.5.2 To Undeploy the hello1 Web Module Using Maven............................................... 6-8 6.4 A Web Module That Uses Java Servlet Technology: The hello2 Example ......................... 6-8 6.4.1 Mapping URLs to Web Components................................................................................ 6-9 6.4.2 Examining the hello2 Web Module................................................................................... 6-9 6.4.2.1 To View the hello2 Web Module Using NetBeans IDE .......................................... 6-9 6.4.3 Running the hello2 Example .........................................
View Full Document

  • Spring '14
  • Hooks
  • ........., Java Community Process, JavaServer Faces Technology

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes