Developing Portable Applications for the Java 2 Platform, Enterprise Edition (J2EE )

Similar documents
Introduction. Enterprise Java Instructor: Please introduce yourself Name Experience in Java Enterprise Edition Goals you hope to achieve

ITdumpsFree. Get free valid exam dumps and pass your exam test with confidence

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER

UNIT-III EJB APPLICATIONS

Deccansoft Software Services. J2EE Syllabus

NetBeans IDE Field Guide

Designing a Distributed System

Enterprise JavaBeans TM

index_ qxd 7/18/02 11:48 AM Page 259 Index

Oracle 10g: Build J2EE Applications

EJB ENTERPRISE JAVA BEANS INTRODUCTION TO ENTERPRISE JAVA BEANS, JAVA'S SERVER SIDE COMPONENT TECHNOLOGY. EJB Enterprise Java

History of Enterprise Java

Enterprise JavaBeans. Layer:01. Overview

Enterprise JavaBeans (I) K.P. Chow University of Hong Kong

Writing Portable Applications for J2EE. Pete Heist Compoze Software, Inc.

J2EE Interview Questions

Introduction to Java EE (J2EE)

Implementing a Web Service p. 110 Implementing a Web Service Client p. 114 Summary p. 117 Introduction to Entity Beans p. 119 Persistence Concepts p.

Java Enterprise Edition

Java 2 Platform, Enterprise Edition: Platform and Component Specifications

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

Component-Based Software Engineering. ECE493-Topic 5 Winter Lecture 26 Java Enterprise (Part D)

Overview p. 1 Server-side Component Architectures p. 3 The Need for a Server-Side Component Architecture p. 4 Server-Side Component Architecture

Chapter 6 Enterprise Java Beans

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

Outline. Project Goal. Overview of J2EE. J2EE Architecture. J2EE Container. San H. Aung 26 September, 2003

IBM. Enterprise Application Development with IBM Web Sphere Studio, V5.0

Oracle9iAS Tech nicaloverview

Fast Track to EJB 3.0 and the JPA Using JBoss

Enterprise JavaBeans. Layer 05: Deployment

Conception of Information Systems Lecture 8: J2EE and EJBs

What we need. Agenda. What s J2EE. Challenges of Enterprise Application Development

Problems in Scaling an Application Client

Borland Application Server Certification. Study Guide. Version 1.0 Copyright 2001 Borland Software Corporation. All Rights Reserved.

Application Servers in E-Commerce Applications

What's New in J2EE 1.4

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

Agenda. Summary of Previous Session. Extreme Java G Session 3 - Main Theme Java Core Technologies (Part I)

Building the Enterprise

The Developer s Guide to Understanding Enterprise JavaBeans. Nova Laboratories

Enterprise JavaBeans, Version 3 (EJB3) Programming

Enterprise Java Beans

The Details of Writing Enterprise Java Beans

BEA WebLogic. Server. Programming WebLogic Enterprise JavaBeans

Enterprise Java and Rational Rose -- Part I

JBuilder. Getting Started Guide part II. Preface. Creating your Second Enterprise JavaBean. Container Managed Persistent Bean.

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Java EE 7: Back-End Server Application Development

presentation DAD Distributed Applications Development Cristian Toma

(9A05803) WEB SERVICES (ELECTIVE - III)

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Distributed Transactions and PegaRULES Process Commander. PegaRULES Process Commander Versions 5.1 and 5.2

J2EE - Version: 25. Developing Enterprise Applications with J2EE Enterprise Technologies

Enterprise Java Security Fundamentals

~ Ian Hunneybell: CBSD Revision Notes (07/06/2006) ~

Distributed Multitiered Application

Proposed Final. Draft. Java 2 Platform Enterprise Edition Specification, v1.3. Sun Microsystems, Inc. Proposed Final Draft - 10/20/00

CO Java EE 7: Back-End Server Application Development

Projects. How much new information can fit in your brain? Corporate Trainer s Profile TECHNOLOGIES

J2EE Packaging and Deployment

WebSphere 4.0 General Introduction

SCBCD EXAM STUDY KIT. Paul Sanghera CX JAVA BUSINESS COMPONENT DEVELOPER CERTIFICATION FOR EJB MANNING. Covers all you need to pass

Enterprise JavaBeans. Layer:07. Entity

BEA WebLogic Server. and BEA WebLogic Express. Introduction to BEA WebLogic Server 6.1

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p.

Index. attributes, visual modeling of, , 565, 566, 567, 568 authentication, Authorization Constraint wizard, , 396

Business-Driven Software Engineering (6.Vorlesung) Bean Interaction, Configuration, Transactions, Security Thomas Gschwind <thg at zurich.ibm.

BEA WebLogic Server. Programming WebLogic Enterprise JavaBeans

Multi-tier architecture performance analysis. Papers covered

Outline. Chapter 5 Application Server Middleware. Types of application server middleware. TP monitors CORBA Server-side components and EJB Summary

Outline. Chapter 5 Application Server Middleware WS 2010/11 1. Types of application server middleware

Course Content for Java J2EE

WebSphere Application Server - Overview

J2EE for Glast. Matthew D. Langston (SLAC) 4/25/2004

Lab2: CMP Entity Bean working with Session Bean

SUN Enterprise Development with iplanet Application Server

OracleAS 10g R3: Build J2EE Applications II

Plan. Department of Informatics. Advanced Software Engineering Prof. J. Pasquier-Rocha Cours de Master en Informatique - SH 2003/04

J2EE Development with Apache Geronimo. Aaron Mulder Chariot Solutions

BEA WebLogic. Server. Introduction to WebLogic Server and WebLogic Express

Introduction to componentbased software development

PLATFORM TECHNOLOGY UNIT-5

Outline. Chapter 5 Application Server Middleware. Types of application server middleware. TP monitors CORBA Server-side components and EJB Summary

Enterprise JavaBeans. Layer:08. Persistence

Understanding and Designing with EJB

BEAWebLogic. Server. Introduction to WebLogic Server and WebLogic Express. Version 8.1 Revised: June 28, 2006 Part Number:

Data Management in Application Servers. Dean Jacobs BEA Systems

University of Toronto

Introduction to J2EE...xxvii. Chapter 1: Introducing J2EE... 1 Need for Enterprise Programming... 3 The J2EE Advantage... 5

Erik Dörnenburg JAOO 2003

BEAAquaLogic. Service Bus. Interoperability With EJB Transport

A Guide to Porting Applications

Appendix A - Glossary(of OO software term s)

Advanced Java Programming

Using JNDI from J2EE components

Installing and Configuring the Runtime Processes 2

SUN Sun Certified Enterprise Architect for J2EE 5. Download Full Version :

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition

Web Design and Applications

The team that wrote this redbook

Transcription:

Developing Portable Applications for the Java 2 Platform, Enterprise Edition (J2EE ) Kevin Osborn, Philippe Hanrigou, Lance Andersen Sun Microsystems, Inc.

Goal Learn how to develop portable applications for the J2EE 1.3 platform 2

Learning Objectives Understand the value of the J2EE brand Identify key areas of J2EE technology which have portability limitations Identify areas of J2EE technology which allow vendors to extend 3

Speaker s Qualifications Kevin Osborn is the manager of the Compatibility Test Suite (CTS) team for Java 2 Platform, Enterprise Edition (J2EE) Lance Andersen is a technology specialist in Java Partner engineering, and has extensive experience with different implementations for the J2EE platform Philippe Hanrigou is a CTS engineer, specializing in the EJB TM specification and interoperability technologies CTS is the largest collection of portable, J2EE platform-based applications with over 15,000 test cases 4

Merits of the Java 2 Platform, Enterprise Edition (J2EE ) Faster Solution Delivery Time to Market Freedom of choice Simplified Integration End-to-end solutions 5

Agenda The Value of the Java Compatible, Enterprise Edition Brand J2EE Compatibility Test Suite, a collection of portable applications J2EE CTS learning experiences Summary Q&A 6

The Value of the Java Compatible, Enterprise Edition Brand 7

Delivering Compatibility Integrated Application Environment Platform and API specifications Reference implementation of APIs Compatibility Test Suite A Brand J2EE BluePrints design guidelines 8 8

J2EE Platform: Licensees ATG BEA Systems Borland Broadvision Brokat CA Cape Clear Compaq Data Direct Fujitsu Hitachi HP Bluestone IBM In-Q-My Interworld IONA iplanet Lutris Macromedia NEC Nokia Oracle Persistence Pramati SAS Institute Secant SilverStream Sonic Spiritsoft Sybase Talarian Tibco TMax Togethersoft Trifork WebGain 9

1.3 Compatible Products Are Here! 10

J2EE Platform: Compatibility Goals Write Once, Run Anywhere Portable applications will run in all compatible servers Compatibility Test Suite tests conformance to the specifications Compatibility challenges Portability of test suite Vendor value add Don t be confused! 11

CTS: Largest Collection of Portable Applications for the J2EE 1.3 Release Largest collection of J2EE 1.3 platformenabled applications: 1800+.ear files 15,000+ tests Intense exposure to application portability Every licensee has to successfully deploy and run all these tests Non-portable means invalid Test is challenged if its relies on any non-portable feature or behavior 12

J2EE 1.3 Platform Architecture Applet Container Applet HTTP SSL Web Container EJB Container JSP Servlet EJB J2SE Application Client Container HTTP SSL JAAS JMS JTA Java Mail JAF J2SE JAXP JDBC Connectors JAAS JMS JTA Java Mail JAF J2SE JAXP JDBC Connectors Database Application Client JDBC JAXP JAAS JMS 13 J2SE

Enterprise JavaBeans (EJB ) Specification: Learning Experiences 14

EJB Spec: State Gotchas Stateless beans Do not retain any conversational state Entity beans Do not rely on state that you do not persist (ejbload / ejbstore) Can come into READY state: Through ejbcreate()(but not only) Through ejbactivate() (e.g., No pooling!) Initialize non-persistent member variables in setentitycontext() e.g., Getting a reference to the environment naming context (java:comp/env) 15

EJB Spec: RemoteException Background: EJB 1.0 spec Allowed business methods to throw a java.rmi.remoteexception (bean class) To indicate a non-application exception Deprecated since the EJB 1.1 release Portable beans should throw the javax.ejb.ejbexception (or another RuntimeException) CMP 2.0 beans must not throw the RemoteException (bean class) 16

EJB Spec: RMI-IIOP Types IIOP can be the underlying protocol Valid RMI-IIOP types Java TM Language to IDL Mapping specification ( Java IDL ) Argument and return types For the Home and Remote Interfaces Session beans instance variables Mark all non-serializable instance variables as transient A few additional valid types (EJB.7.4.1) 17

CMP 2.0: A New Persistence Model CMP 2.0 now only supports 4 transaction attributes (EJB.17.4.1) Only Required, RequiresNew or Mandatory should be used Use NotSupported, Supports, Never is not portable (support is optional) Use unique abstract schema names per ejb-jar file (EJB.11.2.3) Undeploy does not guarantee persistence cleanup 18

EJB Spec: New Query Language Finder methods All finder method defined in Home / LocalHome interfaces Must have a corresponding <query> element One exception: findbyprimarykey(...) EJB QL consideration Container and databases may not support the use of the optional, third argument of the LOCATE function Avoid use of this argument 19

Java Naming and Directory Interface (JNDI): Learning Experiences 20

JNDI Initial Context Requirement java:comp/env naming context is required for all lookups Recommended subcontexts java:comp/env/jdbc java:comp/env/ejb java:comp/env/url java:comp/env/mail java:comp/env/jms Use unique JNDI names 21

JNDI: INS:CosNaming Always use INS compliant names Especially true for interoperability Path separators is a concern: dot is not valid Examples of valid INS names: MyApplication_foo_bar_myEJB corbaname:iiop:1.2@<host>:<port>#yourapp_foo_yourejb 22

Using the Component Environment Context InitialContext ctx = new InitialContext(); Context envcontext = nctx.lookup("java:comp/env"); Always use the component naming environment to lookup administered object (portable and easy) e.g., JMS Queue Connection Factories Session beans A reference to the bean environment context (and any of its sub-contexts) can always be passivated A reference to the Initial Context might not be! 23

Java Message Service (JMS) API and MDB: Learning Experiences 24

JMS API: Pre-deployment No standard way To define MDB JMS destination bindings To create/configure (prior to deployment) JMS Connection Factories JMS Destination Document pre-deployment configuration instructions Eventually provide a helper application/script to create these JMS administered objects 25

JMS API: Audit Your Cleanup Code JMS sessions and connections: close them explicitly (sessions first) myjmssession.close(); myjmsconnection.close(); MDB using BMT: commit or rollback all your JMS sessions explicitly ut.commit(); Durable subscriptions: unsubscribe when done tsub.close(); tsession.unsubscribe(...); 26

JMS API: Robust Error Handling 27 Common problem ut.begin(); try { /* Do something */ } catch(someapplicationexception e) { /* Recover from exception */ /* No explicit cleanup and/or commit */ } /* cleanup code */ ut.commit(); Do not rely on (potential) auto-commit behavior; use finally blocks! Applicable to all Bean Managed Transactional code (not only JMS)

JMS API: Close Connections (Revisited) Developer writes code assuming to deal with 2 distinct Connection Factories Tcf1 = (TopicConnectionFactory) nctx.lookup("java:comp/env/jms/tfact1"); tcf2 = (TopicConnectionFactory) nctx.lookup("java:comp/env/jms/tfact2"); tcon1 = tcf1.createtopicconnection(...);... /* Do not close tcon1 */ tcon2 = tcf2.createtopicconnection(...); /* OK? */... tcon1.close(); tcon2.close(); Deployer binds TFact1 and TFact2 to the same JMS factory (JNDI name + client ID) client ID already in use at /* OK? */ 28

Back-end Learning Experiences 29

Java DataBase Connectivity API (JDBC ): Clarifications J2EE 1.3 implementation must be able to return a JDBC 2.0 compliant DataSource via JNDI Additional requirements are listed in the JDBC section of the J2EE 1.3 Platform specification (J2EE.6.2.2.3) ResultSet types TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE are not required for J2EE 1.3 30

Security Learning Experiences TM 31

Security: J2SE Platform-based Security Permissions J2SE security permissions: J2EE components can only expect to get the J2EE security permissions set as defined in J2EE 1.3 Specification Table 6.2 Application components that need permissions not in this minimal set should describe their requirements in their documentation 32

Security: Method Permissions When security roles are defined, always specify method permissions J2EE 1.2 release The server may interpret unspecified to be none or all J2EE 1.3 release It is the responsibility of the Deployer to assign method permissions for all of the unspecified methods Use the <unchecked>/<exclude-list> elements 33

Security: Login Code Keep login code in a separate class that can be ported J2EE 1.2 release does not require a specific authentication mechanism (e.g., JAAS) J2EE 1.3 release requires JAAS, but it is a good practice to keep the LoginModule code from the application code 34

Packaging Learning Experiences TM 35

Packaging: EJB References EJB Remote references Need to package (or reference) Home and Remote interfaces even if part of the same.ear file EJB 1 Ejb-jar 1 EJB local references All beans packaged in the same ejb-jar EJB 2 Ejb-jar 2 A jar file can reference another jar file using a Class-Path header in its Manifest file (J2EE.8.1.1.2) 36

Packaging: Transaction Attributes Must not specify any transaction attributes for: Session beans All methods of the Home interface All the methods of javax.ejb.object() and javax.ejb.ejblocalobject() CMP 2.0 gethandle() getejbhomehandle() getejbhome() getejbmetadata() getejblocalhome() GetPrimaryKey() IsIdentical() 37

Packaging: JSP Tags (JavaServer Pages Specification-based Tags) It is invalid to have TLDs which refer to missing Tag classes Even if your application does not actually use this JSP Tag Make sure you package all the Tag classes for all the Tags defined in your TLD 38

Packaging: Case Sensitivity Deployment descriptors: The content of the XML elements is in general case sensitive (J2EE.8.4) Exact behavior of the deployment tool is unspecified Example: <ejb-name>, CMP 2.0 relationships <multiplicity>one</multiplicity> 39 <multiplicity>one</multiplicity> Invalid

J2EE 1.3 Platform, Interoperability: Learning Experiences 40

Interoperability RMI-IIOP is required Transaction interoperability Optional feature of the EJB 2.0 spec Code your EJB component so that it handles containers that support AND do not support transaction interoperability See EJB 2.0 specification section 19.6.2.2 for details 41

Interoperability: CORBA Names Must use a valid corbaloc or corbaname corbaloc:iiop:1.2<host>:<port>/<objectkey> Host, port and objectkey are values corresponding to the root CosNaming service of the server corbaname:iiop:1.2@<host>:<port>#rmi:/lance/asessionejb Info to the left of the # is unique to the App Server which is looking up the EJB component Everything to the right of the # indicates how to find the EJB component on the remote server 42

RMI-IIOP / Java IDL Stubs and Ties J2EE platform-based components can be clients of any RMI-IIOP or Java IDL object Java-To-IDL (RMI-IIOP) describes how to create portable stub and tie classes POA support is not mandated Unlike EJB stubs and ties, these must be packaged with the application Only application clients can create and export RMI-IIOP and Java IDL objects 43

Non-Portable Features Integration 44

Use of Non-Portable/ Optional Features An application for the J2EE platform might want to use: An optional API or feature (e.g., Transaction interoperability) Application server specific extensions Improved performance, functionality beyond the scope of the J2EE 1.3 platform, In such case Generalize the proprietary API: Abstraction layer Applications access implementation specific code only through this abstraction layer 45

Example 1: The CTS Porting Package CTS must use a couple of non-portable/ unspecified API features Deployment/undeployment, pre-deployment configuration of DB and JMS API administered objects, A porting package is included Abstracts implementation specific code Portable applications access implementation specific code only through interfaces Licensees provide their implementations of these interfaces JDBC SQL statements are read at runtime 46

Example 2: Use of Local Interfaces From the Web Container Support for use of EJB local interfaces from the Web container is optional Your application performance might benefit from using this (non-portable) feature Even if you only use local interfaces always provide a remote view of the beans accessed by your JSP/Java Servlet components Do not rely on any side effect of the local client view (e.g., Sharing of objects) Your application can easily be ported to any J2EE 1.3 platform-compliant application server 47

Summary Read the specifications carefully Only take advantage of required platform semantics Be aware of vendor value add Avoid use of optional packages 48

If You Only Remember One Thing Read the specifications carefully! Write your apps to the spec. 49