how to debug oracle application development framework applications s316887

134

Upload: rpgudla

Post on 27-Oct-2014

67 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: How to Debug Oracle Application Development Framework Applications S316887
Page 2: How to Debug Oracle Application Development Framework Applications S316887

<Insert Picture Here>

How to Debug Oracle Application Framework Applications

Lynn MunsingerSenior Principal Product ManagerOracle JDeveloper & ADF

Page 3: How to Debug Oracle Application Development Framework Applications S316887

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions.The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Page 4: How to Debug Oracle Application Development Framework Applications S316887

"My ADF Application's Not Working… Help!"

• "I see an exception stack trace…"• "I get data, but it's the wrong data…"• "I expect to see data, but no rows appear…"• "My application is slow…"

Page 5: How to Debug Oracle Application Development Framework Applications S316887

Start by Getting More Contextual Informationand Trying to Isolate the Problem

• Enable Debug Diagnostics– Verbose trace of what happens before problem occurs

• Try to reproduce using the BC Tester– Avoid web app restart delay as you narrow down the problem

• Try to reproduce using a standalone test client– No UI interaction required = fastest option of all

Page 6: How to Debug Oracle Application Development Framework Applications S316887

HOW TO…

Enable Diagnostic Logging

Page 7: How to Debug Oracle Application Development Framework Applications S316887

Enable Diagnostic Logging► Creating Run Config with ADF Logging Enabled

Main Menu: { Tools | Preferences… }

Page 8: How to Debug Oracle Application Development Framework Applications S316887

Enable Diagnostic Logging► Create New Run Configuration

Main Menu: { Application | Project Properties… }

Page 9: How to Debug Oracle Application Development Framework Applications S316887

Enable Diagnostic Logging► Name New Run Configuration

Page 10: How to Debug Oracle Application Development Framework Applications S316887

Enable Diagnostic Logging► Edit New Run Configuration

Page 11: How to Debug Oracle Application Development Framework Applications S316887

Enable Diagnostic Logging► Add –Djbo.debugoutput=console to Java Options

Page 12: How to Debug Oracle Application Development Framework Applications S316887

Enable Diagnostic Logging► Choosing Active Run Configuration

Page 13: How to Debug Oracle Application Development Framework Applications S316887

HOW TO

Debug with the Business Components Tester

Page 14: How to Debug Oracle Application Development Framework Applications S316887

Debug with the Business Components Tester► Right-click Debug to Use Default Configuration

Page 15: How to Debug Oracle Application Development Framework Applications S316887

Debug with the Business Components Tester► Debug Specific Configuration In AM Editor

Page 16: How to Debug Oracle Application Development Framework Applications S316887

Debug with the Business Components Tester► Double-click App Module to See Client Methods

Page 17: How to Debug Oracle Application Development Framework Applications S316887

Debug with the Business Components Tester ► Choose Method, Enter Params, and Execute

Page 18: How to Debug Oracle Application Development Framework Applications S316887

Debug with the Business Components Tester ► Double-click View Instance to See Data

Page 19: How to Debug Oracle Application Development Framework Applications S316887

Debug with the Business Components Tester ► Alternatively, Show Data in Editable Table

Page 20: How to Debug Oracle Application Development Framework Applications S316887

Debug with the Business Components Tester ► If Needed, View Object Operations Available

Page 21: How to Debug Oracle Application Development Framework Applications S316887

Debug with the Business Components Tester ► Choose Method, Enter Params, and Execute

Page 22: How to Debug Oracle Application Development Framework Applications S316887

HOW TO

Create a Command-LineTest Client Program

Page 23: How to Debug Oracle Application Development Framework Applications S316887

Create a Command-Line Test Client Program► Create a New Java Class with main() Method

Page 24: How to Debug Oracle Application Development Framework Applications S316887

Create a Command-Line Test Client Program► Use bc4jclient Code Template

Page 25: How to Debug Oracle Application Development Framework Applications S316887

Create a Command-Line Test Client Program► Replace AM, Config, VO Names Appropriately

Page 26: How to Debug Oracle Application Development Framework Applications S316887

Create a Command-Line Test Client Program► Write Code to Work with AM and/or VO

Page 27: How to Debug Oracle Application Development Framework Applications S316887

HOW TO

Export Debugger Call Stack and Exact JDev/ADF Version

Page 28: How to Debug Oracle Application Development Framework Applications S316887

Export Debugger Call Stack► Visit Stack Window Preferences

Page 29: How to Debug Oracle Application Development Framework Applications S316887

Export Debugger Call Stack► Enable Line Numbers in Stack Window

Page 30: How to Debug Oracle Application Development Framework Applications S316887

Export Debugger Call Stack► Export the Stack to a Text File

Page 31: How to Debug Oracle Application Development Framework Applications S316887

Copying Exact Build Information to the Clipboard

Page 32: How to Debug Oracle Application Development Framework Applications S316887

TIP

Having the ADF Source Code Makes a Big Difference

Page 33: How to Debug Oracle Application Development Framework Applications S316887

Without ADF Source…Parameter Insight Only Gives Data Types

Page 34: How to Debug Oracle Application Development Framework Applications S316887

With ADF Source…Parameter Insight Shows Parameter Names, Too

Page 35: How to Debug Oracle Application Development Framework Applications S316887

Without ADF Source…Quick JavaDoc Does Not Work At All

Page 36: How to Debug Oracle Application Development Framework Applications S316887

With ADF Source…Quick JavaDoc Gives You Instant Overviews

Page 37: How to Debug Oracle Application Development Framework Applications S316887

Without ADF Source…Only Method Breakpoints in Fwk, and No Stepping

Page 38: How to Debug Oracle Application Development Framework Applications S316887

With ADF Source…Break Anywhere, Step Into Anything

Page 39: How to Debug Oracle Application Development Framework Applications S316887

Without ADF Source…Go To Declaration Shows Only Decompiled Stub

Page 40: How to Debug Oracle Application Development Framework Applications S316887

With ADF Source…Go To Declaration Really Goes There

Page 41: How to Debug Oracle Application Development Framework Applications S316887

With ADF Source, and Find Usages…Find Where Exceptions Thrown, Properties Used, Diagnostics Printed, and More

• PropertyConstantsPropertyMetadata(oracle.jbo.common)

– Configuration Property Definitions

• CSMessageBundle(oracle.jbo.common)

– ADF Business ComponentsRuntime Error Messages

• ADFmMessage(oracle.adf.model)

– ADF Model Data Binding Runtime Error Messages

Page 42: How to Debug Oracle Application Development Framework Applications S316887

Requesting the ADF Source Code Is Painless

1. Open a Service Request on Metalink– Indicate exactly the JDev/ADF release you are working with

(for example, 11.1.1.1.3)

2. Have the Legal Agreement Signed– Typically VP or higher but depends on the company– Signer's company must be same as the CSI number

3. Return the Legal Agreement to Oracle– Scan the agreement and email it

4. Support Updates the SR with Download Link– Download the source

Page 43: How to Debug Oracle Application Development Framework Applications S316887

HOW TO

Set Up and Use Oracle ADF Source for Debugging

Page 44: How to Debug Oracle Application Development Framework Applications S316887

Set Up Oracle ADF Source for Debugging► Create New Library

Main Menu: { Tools | Manage Libraries… }

Page 45: How to Debug Oracle Application Development Framework Applications S316887

Set Up Oracle ADF Source for Debugging► Name Library and Add Source Path Entry

Page 46: How to Debug Oracle Application Development Framework Applications S316887

Set Up Oracle ADF Source for Debugging► Select ADF Source Zip File

Page 47: How to Debug Oracle Application Development Framework Applications S316887

Use Oracle ADF Source for Debugging ► In Project Properties, Add Library

Page 48: How to Debug Oracle Application Development Framework Applications S316887

Use Oracle ADF Source for Debugging ► Select ADF Source Library You Created Earlier

Page 49: How to Debug Oracle Application Development Framework Applications S316887

Use Oracle ADF Source for Debugging► With Library in Your Classpath, Ready to Debug

Page 50: How to Debug Oracle Application Development Framework Applications S316887

HOW TO DEBUG

Exception with Stack Trace

Page 51: How to Debug Oracle Application Development Framework Applications S316887

Symptom: NullPointerException on Navigation

Page 52: How to Debug Oracle Application Development Framework Applications S316887

Log Window Gives More InfoDouble-click To Maximize Tabbed Contents

Page 53: How to Debug Oracle Application Development Framework Applications S316887

Framework Caught Unexpected ExceptionScroll Down to See Original Cause

Page 54: How to Debug Oracle Application Development Framework Applications S316887

NullPointerException in EmpImpl.validateEmp()Click on the Hyperlink to Open Source

Page 55: How to Debug Oracle Application Development Framework Applications S316887

If getComm() Returns null, We Have a ProblemVerify Your Suspicion Using Exception Breakpoint

Page 56: How to Debug Oracle Application Development Framework Applications S316887

In the Breakpoints Tab…Create a New Exception Breakpoint

Page 57: How to Debug Oracle Application Development Framework Applications S316887

Use In-Field Classname Insight or Dropdownto Specify Exception Class Name

Page 58: How to Debug Oracle Application Development Framework Applications S316887

Debug the Application Again Using theBusiness Components Browser

Page 59: How to Debug Oracle Application Development Framework Applications S316887

Unrelated Code Also Throws NullPointerException!Delay Enabling Breakpoint to Avoid Stopping Here

Page 60: How to Debug Oracle Application Development Framework Applications S316887

Navigate to Source of ApplicationModuleImplUsing Go to Java Type…

Page 61: How to Debug Oracle Application Development Framework Applications S316887

Type Enough of the Class to Narrow the ListCamelcase Matching Saves Keystrokes

Page 62: How to Debug Oracle Application Development Framework Applications S316887

Navigate to prepareSession() MethodUsing Quick Outline

Page 63: How to Debug Oracle Application Development Framework Applications S316887

Type to Narrow the Method ListUse Arrows+[Enter] or Mouse to Navigate

Page 64: How to Debug Oracle Application Development Framework Applications S316887

Set a Breakpoint in prepareSession()This Occurs After AM is Checked Out of Pool

Page 65: How to Debug Oracle Application Development Framework Applications S316887

Edit Exception Breakpoint to Add Group Name

Page 66: How to Debug Oracle Application Development Framework Applications S316887

Name the Breakpoint Group Anything You Like

Page 67: How to Debug Oracle Application Development Framework Applications S316887

Edit the prepareSession() Breakpoint

Page 68: How to Debug Oracle Application Development Framework Applications S316887

Visit the Actions Tab

Page 69: How to Debug Oracle Application Development Framework Applications S316887

Configure the Action to Enable a Breakpoint GroupChoosing Yours from the List

Page 70: How to Debug Oracle Application Development Framework Applications S316887

Disable the Breakpoint Group By DefaultAction Will Enable it at prepareSession() Time

Page 71: How to Debug Oracle Application Development Framework Applications S316887

Debug Again. Only Stop at NullPointerExceptionAfter First Hitting the prepareSession() Breakpoint

Page 72: How to Debug Oracle Application Development Framework Applications S316887

Add a Watch Expression for getComm()to Inspect Value of the Comm Attribute

Page 73: How to Debug Oracle Application Development Framework Applications S316887

Suspicion is Confirmed, It's Null

Page 74: How to Debug Oracle Application Development Framework Applications S316887

Add Null Protection to Fix the BugDebug and Test to Verify Your Fix

Page 75: How to Debug Oracle Application Development Framework Applications S316887

Summary of Techniques Used in the Example

• Exception breakpoints– To stop when exception is thrown– Use more generic or more specific exception type as needed

• Breakpoint Groups and Actions– To avoid stopping at uninteresting occurrences

• Watch Expressions– To easily inspect the value of attributes

Page 76: How to Debug Oracle Application Development Framework Applications S316887

HOW TO DEBUG

"Wrong Data" Problems

Page 77: How to Debug Oracle Application Development Framework Applications S316887

Overview of Application to Debug

tfParam_deptno => #{pageFlowScope.deptno}

VarDeptno =#{pageFlowScope.deptno}

<af:setActionListener from="#{bindings.Deptno.inputValue}" to="#{requestScope.deptno}"

tfParam_deptno =#{requestScope.deptno}

Page 78: How to Debug Oracle Application Development Framework Applications S316887

Symptom: Choose Department "ACCOUNTING" (10)But See Employees for All Departments

Page 79: How to Debug Oracle Application Development Framework Applications S316887

Set a Breakpoint in ViewObjectImplbindParametersForCollection() Method & Debug

Page 80: How to Debug Oracle Application Development Framework Applications S316887

Breakpoint Hit: View Object Query is Executing,But Which One?

Page 81: How to Debug Oracle Application Development Framework Applications S316887

This Query Execution is for VO InstanceNamed "DepartmentList" (for Dropdown List)

Page 82: How to Debug Oracle Application Development Framework Applications S316887

Edit the Breakpoint to Make it Break Only For the"EmpView1" View Object We're Interested In

Page 83: How to Debug Oracle Application Development Framework Applications S316887

Edit Breakpoint, Add Conditional Expression toStop Only For "EmpView1" VO Instance

Page 84: How to Debug Oracle Application Development Framework Applications S316887

Choose a Department, Click Button toCall the Task Flow

Page 85: How to Debug Oracle Application Development Framework Applications S316887

Bind Variable VarDeptno has null value Next, Need to Figure Out Why

Page 86: How to Debug Oracle Application Development Framework Applications S316887

Toggle Breakpoint on TaskFlow Call Activityand Repeat the Test

Page 87: How to Debug Oracle Application Development Framework Applications S316887

At Breakpoint, Use ADF Structure to Inspect the Request Scope: deptno Attribute Set Correctly

Page 88: How to Debug Oracle Application Development Framework Applications S316887

Drilldown to Task Flow, Toggle Breakpoint onDefault MethodCall Activitity, then Continue

Page 89: How to Debug Oracle Application Development Framework Applications S316887

At the Breakpoint, Use ADF Structure to Inspectthe Task Flow: pageFlowScope.deptno Set OK

Page 90: How to Debug Oracle Application Development Framework Applications S316887

Navigate to the Method Call Activity's Page Def

Page 91: How to Debug Oracle Application Development Framework Applications S316887

Toggle Breakpoint on ExecuteWithParams Action,Then Continue Execution

Page 92: How to Debug Oracle Application Development Framework Applications S316887

At the Breakpoint, Explore the Value of MethodAction's Arguments: VarDeptno is null Incorrectly!

Page 93: How to Debug Oracle Application Development Framework Applications S316887

Explore Action Binding Runtime Metadatain ADF Data Window to See EL Expression Used

Page 94: How to Debug Oracle Application Development Framework Applications S316887

View the Whole EL Expression Value,Copy it to Clipboard

Page 95: How to Debug Oracle Application Development Framework Applications S316887

Use EL Evaluator to Test Pasted ExpressionIt Evaluates to null. Notice Typo deplno

Page 96: How to Debug Oracle Application Development Framework Applications S316887

Fix Typo, Test Expression, Copy to Clipboard

Page 97: How to Debug Oracle Application Development Framework Applications S316887

Edit Action Binding, Paste in Correct ExpressionRerun Application to Verify the Fix

Page 98: How to Debug Oracle Application Development Framework Applications S316887

Now, EmpView1's VarDeptno Bind VariableGets Correctly Set to the Selected Department Id

Page 99: How to Debug Oracle Application Development Framework Applications S316887

Summary of Techniques Used in the Example

• Breakpoint in bindParametersForCollection()– To break whenever a View Object's query executes

• Conditional breakpoint expressions– To break only for the EmpView1 VO instance

• Breakpoints on Task Flow Activities– To break on task flow call and method call (among others)

• ADF Structure and ADF Data Windows– To Inspect ADF context, scopes, task flow artifacts

• Breakpoint on Action Bindings in Page Definition– To break just before action occurs

• EL Evaluator Window– To test EL expressions in correct runtime context

Page 100: How to Debug Oracle Application Development Framework Applications S316887

HOW TO DEBUG

"No Data" Problems

Page 101: How to Debug Oracle Application Development Framework Applications S316887

Symptom: No Data Appears

Page 102: How to Debug Oracle Application Development Framework Applications S316887

At bindParametersForCollection() Breakpoint, Add Watches for getQuery() and params

Page 103: How to Debug Oracle Application Development Framework Applications S316887

Use View Whole Value... to Copy/Paste QueryInto SQL Worksheet, Then Format SQL

Format SQL

Page 104: How to Debug Oracle Application Development Framework Applications S316887

Execute SQL Using Same Bind Variable ValuesAs in the Watches Window. Data OK

Page 105: How to Debug Oracle Application Development Framework Applications S316887

ViewObject FlowChart for "No Data" Problems

Fetched Row null?Fetched

Row null?

bindParametersForCollection()

bindParametersForCollection()

createRowFromResultSet()createRowFromResultSet()

Rows Returned

?

Rows Returned

?

No Results from DBNo Results from DBNo Results from DBNo Results from DB

Discriminator MismatchDiscriminator MismatchDiscriminator MismatchDiscriminator Mismatch

rowQualifies()rowQualifies()Qualifies

for RowSet?

Qualifies for

RowSet?

Failed to QualifyFailed to QualifyFailed to QualifyFailed to Qualify

No

No

Yes

Yes

No

Row Added to RowSetRow Added to RowSet

Yes

while (hasNext())

Page 106: How to Debug Oracle Application Development Framework Applications S316887

createRowFromResultSet() Shows Null RowPoints to Discriminator Mismatch Problem

Page 107: How to Debug Oracle Application Development Framework Applications S316887

Query Retrieves JOB Column Values DifferentFrom the Defined Discriminator Values!

Page 108: How to Debug Oracle Application Development Framework Applications S316887

Changing the Applied View Criteria to Limit Resultsto Only Include Clerks and Salesmen Fixes Problem

Page 109: How to Debug Oracle Application Development Framework Applications S316887

Summary of Techniques Used in the Example

• Breakpoint in bindParametersForCollection()– To examine query statement and bind variable values

• SQL Worksheet– To test query against same database as the application

• Breakpoint in createRowFromResultSet()– To test whether database row is retrieved without error

Page 110: How to Debug Oracle Application Development Framework Applications S316887

TIP

Show Address in Data and Watches Windows to Distinguish Instances

Page 111: How to Debug Oracle Application Development Framework Applications S316887

Use Address in Data and Watches Window► Open Data or Watch Window Preferences

Page 112: How to Debug Oracle Application Development Framework Applications S316887

Use Address in Data and Watches Window► Enable Address Column

Page 113: How to Debug Oracle Application Development Framework Applications S316887

Use Address in Data and Watches Window► Jot Down Address of Objects at One Breakpoint

Page 114: How to Debug Oracle Application Development Framework Applications S316887

Use Address in Data and Watches Window► Compare to Object Address at Other Breakpoint

Page 115: How to Debug Oracle Application Development Framework Applications S316887

HOW TO DEBUG

"Slow Application" Problems

Page 116: How to Debug Oracle Application Development Framework Applications S316887

Logging Executed Queries and Fetched Rows

Page 117: How to Debug Oracle Application Development Framework Applications S316887

Logging Executed Queries and Fetched Rows

Page 118: How to Debug Oracle Application Development Framework Applications S316887

TIP

Watches Can Evaluate Most Java Expressions

Page 119: How to Debug Oracle Application Development Framework Applications S316887

Not Sure What Watch Expression to Use?Find Member in Data Window, Then Watch It

Page 120: How to Debug Oracle Application Development Framework Applications S316887

• Navigate Members Regardless of Access Mode– mInner.mRows[0].mData.mStorage

• Call Functions– getViewObject().findAttributeDef("Dname").getUIHelper().getLabel(getViewObject().getApplicationModule().getSession().getLocaleContext())

Debugger Watch Expressions Can Do Many ThingsFor Example, At a Breakpoint in ViewRowImpl…

Page 121: How to Debug Oracle Application Development Framework Applications S316887

Debugger Watch Expression Tricks (Cont'd)

• Call Methods That Produce Log Output– xmlNode.print(System.out)

Page 122: How to Debug Oracle Application Development Framework Applications S316887

TIP

Customize Debugger Display of Any Object Type

Page 123: How to Debug Oracle Application Development Framework Applications S316887

Customize Debugger Display of Any Object Type ► Select Object Preferences for a Given Entry

Page 124: How to Debug Oracle Application Development Framework Applications S316887

Customize Debugger Display of Any Object Type ► Decide What Fields/Expressions To Show

Page 125: How to Debug Oracle Application Development Framework Applications S316887

Customize Debugger Display of Any Object Type ► Four Changes Are Showing, But Others, Too

Page 126: How to Debug Oracle Application Development Framework Applications S316887

Customize Debugger Display of Any Object Type► Customize Supertype Members, Too, If Needed

Page 127: How to Debug Oracle Application Development Framework Applications S316887

Other Interesting Info in ADF Structure / ADF DataLifecycle Breakpoints and Page UI Component Tree

Page 128: How to Debug Oracle Application Development Framework Applications S316887

Other Interesting Info in ADF Structure / ADF DataADF Context

Page 129: How to Debug Oracle Application Development Framework Applications S316887

New ADF Debugger Improvements► Easily See Binding Values

Page 130: How to Debug Oracle Application Development Framework Applications S316887

Future ADF Debugger Improvements► Easily Explore ViewRows and Entity Objects

Page 131: How to Debug Oracle Application Development Framework Applications S316887

When Debugging Does Not Succeed…Create a Great Test Case for Worldwide Support

• Small investment of your time pays dividends– Simple testcase → faster diagnosis, workaround, fix

• Base the testcase on EMP or HR schema– Eliminates any database setup complications

• Otherwise, provide minimal SQL script– Insert only enough sample data to reproduce problem

• Create a command-line test client– Reduces reproduce instructions to: "Run Test.java"

• Otherwise, give the minimum steps to reproduce– Some issues only occur in context of multi-step, web scenario

Page 132: How to Debug Oracle Application Development Framework Applications S316887

AppendixUseful ADFM/ADFBC Methods for Debugging

Object Method DescriptionViewObjectImpl bindParametersForCollecti

onInspect SQL and bind variables just before executing query

createRowFromResultSet Study each row as its fetched from the databaseViewRowImpl populate Observe row after being populated with fetched

datasetAttributeInternal Examine attribute value being setsetAttributeValues Examine multiple attribute values being set

(typically by LOV mechanism)ApplicationPoolImpl

doCheckout Watch AM as its checked out of the pool

doManagedCheckin See AM as its checked into pool in managed modedoUnmanagedCheckin See AM as its checked into pool in stateless mode

EntityImpl setAttributeInternal Examine attribute value being setExprEval doEvaluate Analyze each Groovy expression being evaluatedJUCtrlActionBinding

doIt Follow any (method) action binding invocation

Page 133: How to Debug Oracle Application Development Framework Applications S316887

QUESTIONS?

Page 134: How to Debug Oracle Application Development Framework Applications S316887