95
1 Oracle Application Server Migrating to OC4J Self-Validation Tech Guide

Oracle Application Server Migrating to OC4J Self-Validation Tech Guide

  • Upload
    deron

  • View
    80

  • Download
    0

Embed Size (px)

DESCRIPTION

Oracle Application Server Migrating to OC4J Self-Validation Tech Guide. Oracle Application Server 10g Architecture. Oracle DB Non-Oracle. Browser. Packaged Apps. Wireless. Web Services. B2B Apps. The different tiers of J2EE. Four different levels of product support. - PowerPoint PPT Presentation

Citation preview

Page 1: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

1

Oracle Application Server Migrating to OC4J

Self-Validation Tech Guide

Page 2: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

2

Packaged Apps

B2B Apps

Oracle DB Non-Oracle

Web Services

Wireless

Browser

Oracle Application Server 10g Architecture

Page 3: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

3

The different tiers of J2EE

Page 4: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

4

Four different levels of product support

• OC4J Standalone• Java Edition• Standard Edition• Enterprise Edition

Page 5: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

5

OC4J Standalone

• The core J2EE Engine• Fully J2EE 1.3 compliant• Small footprint• Built in HTTP Server for testing• OC4J 9.0.4 fully compatible with the latest JVMs (JDK

1.4)• Collection of frameworks and support services

• BC4J• Toplink• Java Object Cache• Etc.

Page 6: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

6

Java Edition

• Adds industry strength to OC4J• Secure Apache HTTP Server (1.3.x)• Oracle Enterprise Manager

• File based repository for deploying components across multiple JVMs

• File based clustering• Development Tools

• JDeveloper• TopLink

Page 7: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

7

Standard Edition

• Adds manageability• Database Managed Repository for application

management• GUI administered clustering and management• Oracle Portal

• Includes restricted use of LDAP and webcache

• Single Signon

Page 8: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

8

Enterprise Edition

• Adds enterprise features• HTTP Web Cache• Full use of LDAP• Oracle Forms and Reports• Oracle Business Intelligence tools• Wireless (option)• Process Connect• Identity Management

Page 9: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

9

Quick start to Oracle OC4J

Page 10: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

10

OC4J Overview

• Complete J2EE implementation• Lightweight & High Performance • Small memory footprint • XML file based configuration for all aspects of

server, web server and applications • Simplified installation, configuration,

deployment and administration • Auto deployment and “Hot” deployment of J2EE

Applications • Clustering, Load balancing and Fail-over of

Web & EJB Apps

Page 11: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

11

Web Container

JavaServerPages

JavaServlets

EJB Container

SessionBeans

EntityBeans

Complete J2EE 1.3 implementation

Oracle Application Server 9i

JMS

JND

I

RM

I

JDB

C

JTA

JavaM

ail

JAF

J2SE

Page 12: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

12

Installation Pre-Requisites

• Identifying the JDK version

%>java -version

java version "1.4.2"

Java(TM) 2 Runtime Environment, Standard

Edition (build 1.4.2-b28)

Java HotSpot(TM) Client VM (build 1.4.2-b28,

mixed mode)

Page 13: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

13

Installing developers edition OC4J Server

• Basic Installation

% cd $oc4j_home

% unzip oc4j.zip• % cd j2ee/home (referenced as <j2ee-home>)• % java -jar oc4j.jar -install

“Oracle9iAS (9.0.4.0.0) Containers for J2EE initialized”

• Directory Structure

Page 14: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

14

Starting up OC4J Server • Startup Commands• % java -jar oc4j.jar <options> • option list:

• -config <file> • -validateXML• -out [file]• -err• -install• -userThreads• -quiet• -version• -help

Page 15: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

15

Verifying the Installation

• Access default Web site

• Using a different port

change port # in …/http-web-site.xml

http://<machine_name>:8888

Page 16: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

16

OC4J Configuration Files Server Configuration Files

application.xml

principals.xml default(http)-web-site.xml

global-web-application.xml

jms.xml

rmi.xml

server.xml

data-sources.xml

OC4J Deployment Specific

orion-web.xml

orion-ejb.xml

orion-application.xml

orion-application-client.xml

J2EE Standard Deployment

web.xml

ejb.xml

application.xml

application-client.xml

Page 17: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

17

OC4J Configuration Files Relationship

server.xml|_______rmi.xml|_______application.xml| |________principals.xml||_______global-web-application.xml||_______http-web-site.xml| |________default-web-app| |________web-app||_______secure-web-site.xml| |________default-web-app| |________web-app||________additional-web-site.xml

|_____default-web-app |_____web-app

Page 18: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

18

Example of Server.xml <application-server>

application-auto-deploy-directory=“<auto-deploy-ears>application-directory="../applications"deployment-directory="../application-deployments”<rmi-config path="./rmi.xml" /><jms-config path="./jms.xml" /> <log> <file path="../log/server.log" /> </log>

<global-application name="default" path="application.xml" /> <global-web-app-config path="global-web-application.xml" /> <web-site path="./http-web-site.xml" /> <web-site path="./oc4j-web-site.xml" />

<application auto-start=“true” deployment-directory=“<dir>” parent=“<parentApps>”<application name="news" path="../applications/news.ear" />

<application name="petstore" path="../applications/petstore.ear" /><application name=“oc4jApp" path=“D:\oc4jApp" />

</application-server>

Page 19: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

19

Example Web-Site.xml

<web-site host=”<hostname>" port=”<n>" cluster-island="1" display-name=”<WebSite>” secure=“false” use-keep-alives=“true”

virtual-hosts=“<hostname>,…,<hostname>” />

<default-web-app application="defaultAppEAR" name="defaultAppWAR" shared=“false” load-on-startup=“false” />

<web-app application=”PetStore" name=”PetWeb" root="/petstore" shared=“false”

load-on-startup=“false” />

<web-app application=”oc4jApp" name=”oc4jWeb" root="/oc4jRoot" shared=“false” load-on-startup=“false” />

<user-web-apps max-inactivity-time=“n>” path=“<path> />

<access-log format=“<format spec>” path=“<path>” suffix=“<suffix>” split=“none|hour|day|week|month” />

Page 20: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

20

Deploying a stand alone EJB JAR File

• Editing XML Files directly1. Edit application.xml

2. Use command line tool

Java –jar admin.jar –deploy –file myEJB.jar

–deploymentName myEJB

<ejb-module id="myEJB" path="../applications/myEJB.jar" />

Page 21: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

21

Deploying a complete EAR file

• Editing XML files directly•Edit server.xml and add

•Edit default-web-site.xml and add

•Access Web application with URL http://localhost:8888/webFront

<application name="myShoppingApp" path=“myApp.ear" />

<web-app application=“myShoppingApp" name=“webFront" root="/webFront" />

Page 22: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

22

Deploy a complete EAR file

• Using admin command line

$ java –jar admin.jar -file myapp.ear-deploymentName myShoppingApp

$ java –jar admin.jar-bindWebApp myShoppingApp webFront /webfront

Page 23: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

23

OC4J Java Database Connectivity

• Fully implements JDBC 2.0 specification• Provides Oracle JDBC drivers

• Type 2 and Type 4 drivers• Certified with Oracle 8, 8i, 9i out of the box

• Implements JDBC 2.0 extensions• Connection pooling, advanced type handling, enhanced

result sets, JNDI data sources, X/A support

• Certified with Merant Type 4 JDBC drivers• Provides access to non-Oracle data sources such as

Informix, Sybase, DB2, SS7

Page 24: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

24

Datasources• Databases & J2EE

• A persistent store for data• Servlets, JSP, EJB (BMP/CMP)

• portable across application servers• No dependency on operational details

• Provides logical to physical mappings• What is a J2EE Datasource

• Provide logical definitions of databases• Developer uses logical representation of a database• Deployer maps to physical datasources• Published in JNDI tree

• J2EE applications use published DataSource objects • Lookup via JNDI using published name

Page 25: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

25

Example of data-sources.xml<data-sources> <data-source

class="com.evermind.sql.DriverManagerDataSource“ name="OracleDS" schema="database-schemas/oracle.xml" location="jdbc/OracleCoreDS" xa-location="jdbc/xa/OracleXADS" ejb-location="jdbc/PooledDS”

pooled-location="jdbc/pooled/DefaultPooledDS connection-driver="oracle.jdbc.driver.OracleDriver" username="scott" password="tiger" url="jdbc:oracle:thin:@<hostname>:<PORT>:<SID>" inactivity-timeout="30" /></data-sources>

Page 26: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

27

orion-ejb-jar.xml

• Contains OC4J specific application settings for EJBS• Various EJB flags such as copyByValue,exclusive-

write-access,isolation-level etc• CMP Entity Bean Persistence to Database

mapping • Tables• Fields• Relationships

• etc

Page 27: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

28

orion-web.xml

• Contains OC4J specific web settings• Must be placed in the same directory as the standard

web.xml• Example of settings

• Clusterable or not• development mode (checks for jsp page changes)• directory-browsing true/false• Local classpath information• EJB/Resource reference mappings..• etc.

Page 28: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

29

jazn-data.xml

• Contains security definitions for JAAS/JAZN security provider

• Roles • Users• Realms

Page 29: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

30

The Migration steps

Page 30: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

31

J2EE Migration

• Can be easy or difficult• Standard J2EE App easy• Proprietary difficult

• Is a moving target, different versions of the app server from a vendor will have different issues

• Web Tier tends to be the easiest to port• EJB tiers can cause issues

• Session beans port easily• Entity beans usually require assistance• Transaction boundries may differ

• Platform specific code may need to be rewritten• E.g. BEA jolt

Page 31: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

32

Basic Steps in any migration

• Identify differences between the application servers

• Remove platform specific proprietary features if possible

• E.g. BEA JOLT, IBM Tags etc

• Port platform specific deployment descriptors• E.g. weblogic-ejb-jar.xml -> orion-ejb-jar.xml

• Port application in tiers starting from data tier (e.g.EJB, webservices) up to client

Page 32: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

33

Step 1 : Convert XML Deployment Descriptor

• Standard J2EE descriptors need little changes and should port easily

• Proprietary J2EE descriptors will need rewriting• E.g. weblogic-ejb-jar.xml equivalent in OC4J is orion-ejb-

jar.xml

• Definition of whats available in OC4J xml files can be obtained online via DTDs or online manuals• http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd

Page 33: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

34

Methods of rewriting XML deployment files

• Manual creation of platform specific deployment descriptor files, using vi,emacs, notepad etc

• XSLT • We provide sample BEA, JBoss & Borland

• Reverse Engineer project into JDeveloper • Let JDeveloper generate deployment descriptors

• Use JDeveloper’s deployment descriptor wizards to assist in the authoring of the deployment descriptors

Page 34: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

35

Example orion-web-ejb.xml JDeveloper Wizard

Page 35: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

36

Step 2 : Migrate EJB Components

• Always migrate data layer first• Usually the most difficult layer to port• Unit Test each EJB as you go along

• JDeveloper is able to create test client stubs which may assist in testing EJBS induvidually

• EJBQL & Finder queries may be different

Page 36: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

37

Step 3 : Migrate Web/Client

• Migrate web/client tier• Usually easier than EJB tier• Beware that Oracle OC4J doesn’t support

client side transactions• JNDI names can be different

• Use JDeveloper to browse JNDI tree in OC4J

• JDEVELOPER IMAGE

Page 37: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

38

Step 4 : Migrate other components

• Datasources • JMS Message Queues• JCA Adaptors

Page 38: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

39

Step 5 : Implementing Clustering

• Options• OC4J Standalone does not support clustering• Java Edition supports file based clustering• Oracle Application Server 10g supports managed

Clustering

• When deploying an application to a managed cluster you must have the <distributable> tag in web.xml

• All session objects are propagated to other nodes in island so they must be serializable

Page 39: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

40

Migration in more detail

Page 40: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

41

Migrating Servlets

Page 41: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

42

Migrating Servlets

• Migrating servlets to 9iAS is usually a smooth & effortless exercise

• Typically no modifications are necessary• However if proprietary server extensions have

been used then they will almost certainly need to be rewritten.

Cont.….Cont.….

Page 42: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

43

IBM Servlet Migration Issues Websphere has non-standard extensions

• Websphere has two mode of deployment• Compatibility Mode: Servlet API 2.0 and 2.1 • Compliance Mode : Servlet 2.2 (partial)

• Websphere Studio generated code not portable

• Websphere servlet extensions packages• Web Application Deployment

• No direct support for war files• custom .servlet file for configuring servlet

Cont.….Cont.….

Page 43: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

44

IBM WebSphere Extensions to Servlets

• Servlet Session Management Package• com.ibm.websphere.servlet.session (replace with J2EE javax.servlet.http.HttpSession)

• Personalization Package• com.ibm.servlet.personalization (replace with 9iAS Personalization )

• Event Manager package• com.ibm.websphere.servlet.event (replace with Servlet 2.3 API:

ServletContextEvent, HttpSessionEvent, HttpSessionBinding event)

• Custom Servlet Filtering package• com.ibm.websphere.servlet.filter (replace with Servlet 2.3 API:

javax.servlet.Filter, FilterConfig)

• Servlet Proxy Package • com.ibm.websphere.servlet.request(replace with HTTPServlet Request, use

servlet chaining features in Servlet 2.3 )• com.ibm.websphere.servlet.response(replace with HTTPServlet Response, use

servlet chaining features in Servlet 2.3 )

Cont….Cont….

Page 44: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

45

Migrating JSPs

Page 45: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

46

Migrating JSPs

• Migrating JSPs to 9iAS typically is a smooth & effortless exercise

• Proprietary tag libraries will need to be ported to either

• Oracle proprietory tag libraries• Custom tag libraryTab

• Tag Libraries can be migrated with ease• Proprietary extensions may need to be ported

• E.g. BEA Weblogic htmlKona

Page 46: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

47

Migrating JSP Custom Tags

• Custom tag libraries can be easily deployed on 9iAS as part of a Web application

• Customer or 3rd Party Tags can be deployed on 9iAS typically with very little changes

• Proprietary custom tags to be replaced with equivalent 9iAS Custom Tags • E.g. IBM Websphere data tags can partially be

replaced by OJSP tags

Page 47: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

48

Using Tag Libraries in OC4J

• 3 Steps to using tag libraries in OC4J• 1. Copy the <tag-library>.tld into /WEB-INF

directory and the necessary classes into WEB-INF/lib

• 2. Edit the web.xml in the /WEB-INF directory<taglib><taglib-uri>mytags</taglib-uri><taglib-location>/WEB-INF/sqltagblib.tld</taglib-location></taglib>

– 3. Use the tags in your JSP

Page 48: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

49

IBM specific JSP Migration issues

• Bean scripting framework(BSF) (Websphere specific )

• Websphere specific Tags and properties• “<SERVLET>“ tag ( replace with “<jsp:include>“

tag)• “<BEAN>“ (replace with <jsp:useBean> tag) • “<CONNECT>”(create your custom tag library or

use OJSP)• “<tsx:repeat>” (create your custom tag library)• “<tsx:dbmodify>” (create your custom tag library)

Page 49: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

50

IBM JSP Migration exampleWebSphere JSP 1.0 to J2EE JSP 1.1

Example<BEANNAME="getQuestionDBBean"TYPE="Samples.YourCo.Poll.GetQuestionDBBean"CREATE="YES"INTROSPECT="NO"SCOPE="request"><PARAM NAME="userID" VALUE="wsdemo"></BEAN>

<jsp:useBeanid="getQuestionDBBean"type="Samples.YourCo.Poll.GetQuestionDBBean"class="Samples.YourCo.Poll.GetQuestionDBBean"scope="request" /><jsp:setProperty name="getQuestionDBBean"property="userID"value="wsdemo" />

Bean Properties in WebSphere

Bean Properties in J2EE JSP (OC4J)

IBM

Page 50: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

51

Migrating EJBs

Page 51: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

52

Migrating EJBs

• Migration of EJBs to OC4J is typically straightforward• Session Beans migrate easier than Entity beans

• Typically little or no code modifications are required• Code modifications often relate to minor JNDI lookup

changes• Implementation-specific adaptations for O/R mapping,

container class generation, & customization of deployment properties are required

Page 52: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

53

Migrating EJBs

• Standard J2EE components and deployment descriptors require almost no modifications

• Implementation-specific dependencies require modification• Hard-coded JNDI context access and lookups• Data source JNDI names and lookups

• Correct and re-generate the code and EJB archive file as required

Page 53: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

54

Migrating Session Beans

• Migration of session beans involves only the generic steps of EJB migration

• Session EJBs are much easier to migrate than Entity EJBs since there are no persistence-related migration issues

Page 54: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

56

Migrating Entity Beans

• Migration of Entity beans involves the generic steps of EJB migration

• Plus • removal of implementation-specific JNDI or

DataSource lookups• Rewriting of specific database deploment

descriptors • E.g. weblogic-ejb-jar.xml to orion-ejb-jar.xml

• Removal of Proprietary APIs or Flags• Transaction Mgmt, Locking, Caching,…

Page 55: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

58

Migrating CMP Entity Beans

• O/R mapping definitions are vendor dependent, require re-generation

• E.g. weblogic-ejb-jar.xml, weblogic-cmp-rdbms-jar*.xml

• Use xslt transformers to give you a head start• Check XML DTD & Documentation for options

available• DataSource for persistence to be configured for OC4J• BEA WebLogic-specific container stub & skeleton

classes need to be removed• OC4J will generate the appropriate equivalent stub &

skeleton classes

Page 56: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

59

Transactions

• OC4J (9.0.4) does not support client side transactions• Need to delegate transaction to middle tier,

prehaps a façade

• BEA & IBM support distributed transactions across multiple JVMs• Presently OC4J does not support this• Planned for a release post 10g

Page 57: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

60

Migrating CMP Entity Beans

• EJB CMP/CMT Transaction management is different• BEA has Read-Commited with versioning• OC4J has this only with Toplink as DAO

• Some differences in CMR• Compound Keys are dealt with slightly differently

• Workarounds including using ejbCreate() and ejbPostCreate()

Page 58: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

61

EJBs need recompilation in following cases

• if EJB uses javax.jts.UserTransaction• replace it with javax.transaction.UserTransaction

• If EJB uses getCallerIdentity() and isCallerInRole(Identity) methods• replace with getCallerPrincipal() and isCallerinRole(String

roleName) respectively

• CMP-EJBs require recompilation • return value of ejbCreate(...)is different in EJB1.0 and 1.1

• interface methods like ejbCreate etc. have different signatures

Page 59: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

62

Migrating CMP Entity Beans

• Standalone OC4J can’t yet use Oracle Sequence number generator to generate Primary Keys

• Workarounds include :• Using Toplink as the CMP Engine• Coding specific ejbCreate() methods

Page 60: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

63

Finder Methods

• Standard finder methods are automatically generated in OC4J, these do not need to be regenerated

• Finder methods in WLS 5.1 use WLQL (WebLogic Query Language), a proprietary query language for specifying selection criteria

• These need to be rewritten

• OC4J uses standard SQL WHERE clauses for specifying selection criteria or EJB-QL

• Some vendors have extended EJB-QL, these changes need to be addressed

• E.g. BEA support Order by

Page 61: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

64

EJBs need recompilation

• Websphere requires every CMP EntityBean define <ejbname>FinderHelper interface• Needs to be removed

IBM

Page 62: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

65

Classloader issues

• Can occur at any tier of the application• Common clashes are different versions of XML parsers• Use OC4J Parent classloader architecture to overcome

this• E.g. adding <web-app-class-loader search-local-classes-first="true"

/> to orion-web-app.xml

• White papers exist which describe how OC4Js class loader work

• See http://otn.oracle.com OC4J whitepapers

Page 63: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

66

JNDI Issues

• In OC4J JNDI is rooted at the application level not at the Server level• Can be solved in some cases by the use of the

<parent> directive in server.xml

• JNDI Clustering is not supported in OC4J 9.0.3, but is supported in OC4J 9.0.4

Page 64: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

67

Implementing Startup classes

• Many application servers support startup classes

• OC4J 10g onwards support startup classes• Steps

• Create a startup class which implements OC4JStartup interface

• Modify server.xml• Ensure class is in a jar file and present in the <init-

library path..> tag in • Add startup class definition to OC4J server.xml file

Page 65: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

68

Implementing Startup classes

• Java classpublic class Oracle9iASStartupSample implements OC4JStartup{   public String preDeploy(Hashtable args, Context context) throws Exception   {    System.out.println(getClass().getName() +“ preDeploy method called");   }

Page 66: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

69

Implementing Startup classes

• server.xml

<init-library path="../applications/startup-class.jar" />

<startup-classes>   <startup-class classname="startup.Oracle9iASStartupSample"

failure-is-fatal="true">       <execution-order>0</execution-order>       <init-param>           <param-name>sampleName</param-name>           <param-value>HowTo-Startup</param-value>       </init-param>   </startup-class></startup-classes>

Page 67: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

70

JDBC Datasources Migration

Page 68: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

71

JDBC Migration issues

• In WebLogic the data source entries are made in the weblogic.properties file

• In OC4J the datasource entries are made in the data-sources.xml file or using Oracle Enterprise Manager

• dbKona code must be replaced with equivalent JDBC 2.0 code

• One should use <ejb-location> tag to get pooled and automatic container spawned transactions

Page 69: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

72

JDBC Migration issues

• IBM Connection Pool manager• com.ibm.db2.jdbc.app.stdext.javax.sql.*;• com.ibm.ejs.dbm.jdbcext.*;• com.ibm.ejs.cm.*• com.ibm.ejs.cm.pool.*• (replace the above packages withJ2EE javax.sql and

java.sql packages)

• data access beans• com.ibm.db package

• Obtaning datasource reference • Need to change Websphere JNDI naming context with

OC4J naming context

Page 70: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

73

Example BEA Proprietary Extensions

BEA Specific OC4J/J2EE Compatible

COM Support None - available from partners & 3rd party

Jolt for WebLogic Plain BEA Jolt for Tuxedo

WebLogic Events JMS

Page 71: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

74

Proprietary Hints and Tips

• Migration hints and tips document• Separate MS-Word documents with hints and

tips for popular J2EE application servers

Page 72: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

75

Clustering and

Deployment

Page 73: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

76

Deployment is easy

• Standalone OC4J• Edit XML Files directly• Use java –jar admin.jar utility

• Using Enterprise Manager• Select OC4J Instance• Then select Deploy EAR, or WAR

Page 74: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

77

Clustering Web Applications

• For clustered web solutions ensure• web.xml has <distributable> tag present• All session objects are serializable

Page 75: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

78

Clustering EJB applications

• OC4J can cluster • stateful and Stateless session beans

• Three types of replication• JVM Termination replication• End of Call Replication• Stateful session context replication• Set using replication attribute of the <session-

deployment> tag in orion-ejb-jar.xml file

• EJB Replication only works with ORMI protocol not RMI over IIOP

• For more info see EJB Developers guide (9.0.4) chapter 10

Page 76: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

79

CORBA Migration

Page 77: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

80

CORBA Security & TX SeriesOC4J has no direct support for the following

• No support for CORBA in OC4J• OC4J 9.0.3 onwards has support for calling

EJBs using IIOP• CORBA model for security is not supported• TX series based code not directly supported

• CICS TP Monitor • ENCINA TP Monitor

Page 78: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

81

JDeveloper 10g

• Since Oracle Jdeveloper 9i we provides an IDE that facilitates • code changes (refactoring, source control etc)• fine-tuning and rapid-deployment of the

applications to OC4J• Wizard based generation of generic and specific

XML files

Page 79: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

82

Example

Migration

Page 80: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

83

Download Page : BEA Developer Center

• Requirement : Weblogic 8.1 installed

• http://developer.bea.com/code/wls.jsp• Download PostCard Demo• This application uses CMP EJB and Servlets

Page 81: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

84

PostCard directories structure

postcard

application

ddl

ejb

html

portlet

META-INF

CSPostcard.java

weblogic-ejb-jar.xml

weblogic-cmp-rdbms-jar.xml

application.xml

META-INF

Page 82: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

85

Create an OC4J-specific deployment descriptor

postcard

application

ddl

ejb

html

META-INF

weblogic-ejb-jar.xml

portlet

CSPostcard.java

orion-ejb-jar.xml

weblogic-cmp-rdbms-jar.xml

application.xml

META-INF

orion-application.xml

Page 83: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

86

Hint : XSL Stylesheet• Use a XSL stylesheet to create orion-ejb-

jar.xml from weblogic-cmp-rdbms-jar.xml• xt weblogic-cmp-rdbms-jar.xml

wls2oc4j-ejbjar.xsl

orion-ejb-jar.xml

Page 84: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

87

Create an OC4J-specific deployment descriptor

• Edit orion-ejb-jar.xml• Move the primary-key into <primary-key>section• Update the persistence-type used by each column

if necessary (LONG for creationDate)

• Create orion-application.xml• Set autocreate-tables="false"  to re-use the

existing table

Page 85: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

88

Extra : Modify web.xml

• Delete <description> tags

• Change :<url-pattern>/CSPostcard/*</url-pattern>

To<url-pattern>/CSPostcard</url-pattern>

Page 86: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

89

Disable WLS specific APIs

• Edit CSPostcard.java• Disable WLS imports (line 31 –32)

//import weblogic.common.*;//import weblogic.time.common.*;

• Change destroy method

• Disable sched (line 371)// private ScheduledTriggerDef sched;

public void destroy() {

try { sched.cancel(); }

catch (TimeTriggerException te)

{ te.printStackTrace(); }

}

public void destroy() {

try { //sched.cancel(); }

catch (Exception te)

{ te.printStackTrace(); }

}

Page 87: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

90

Create datasource

<data-sourceclass="com.evermind.sql.DriverManagerDataSource"name="demoPool"location="jdbc/demoCorePool"xa-location="jdbc/xa/demoPool"ejb-location="examples-dataSource-demoPool"connection-driver="oracle.jdbc.driver.OracleDriver"username="beademo" min-connections="10"password="beademo"min-connections="10"max-connections="30"url="jdbc:oracle:thin:@localhost:1521:ORCL"inactivity-timeout="30"

/>

Page 88: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

91

Create EAR

• Edit setup.bat and set the correct environment variables

• Run setup.bat• Run install.bat

Page 89: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

92

Deploy the application : Standalone OC4J

• Copy /postcard/application/postcard.ear to $OC4J_HOME/j2ee/home/applications

• Add :server.xml<application name="postcard"   path="D:\oc4j\j2ee\home\applications\postcard.ear" 

auto-start="true" />

http-web-site.xml<web-app application="postcard" name="postcard"

root="/postcard" />

Page 90: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

93

Deploy the application : Managed Server

• Command lineDcmctl deployApplication

–f postcard.ear

-co OC4J_Demos

-a PostcardApp

-rc /postcard

Page 91: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

94

Deploy the application : OEM Managed Server

• Using the Oracle Enterprise Manager tool

Page 92: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

95

Deploy the application as usual

• Go to http://localhost:8888/postcard/CSPostcard_send.html

• Check the file orion-ejb-jar.xml in application-deployments/postcard/ejb_postcard.jar directory and make sure that we have :<cmp-field-mapping name="key" persistence-name="idkey" />

instead of

<cmp-field-mapping name="key" persistence-name="key" />

Page 93: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

96

Next Steps

1 - Getting Software

2 – Tech Migration

Page 94: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

97

Resources & Contacts

• Get Product Info & Downloads• http://www.oracle.com/technology/tech/java/oc4j/index.html

• Get Validation Assistance from Oracle• No fees for OPN Partners• Email request to: [email protected]

Page 95: Oracle Application Server  Migrating to OC4J  Self-Validation Tech Guide

98

AQ&