Sei sulla pagina 1di 47

Troubleshooting ADF BC Applications

Copyright 2008, Oracle. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following: Use tools for logging and diagnostics Utilize design-time code validation Make use of FileMon and JUnit Use the JDeveloper profiler Test Web service calls:
Use a sample client to call a Web service Use the JDeveloper HTTP Analyzer


10 - 2

Use the JDeveloper debugger Utilize sources of help


Copyright 2008, Oracle. All rights reserved.

Troubleshooting the Business Service


Test a business service in isolation from views or controllers:
BC Browser Java test clients

JDeveloper and ADF tools for logging and diagnostics:


Java logging ADFLogger ADF Diagnostics


10 - 3

Validate code at design time. Build unit tests with JUnit. Diagnose CLASSPATH and other file access problems: FileMon Diagnose performance problems: JDeveloper Profiler Diagnose Web service problems: HTTP Analyzer, sample Web client Step through code: JDeveloper debugger
Copyright 2008, Oracle. All rights reserved.

Troubleshooting the UI

Java EE Logging (Java Logger, ADF Logger) Design-time troubleshooting Using the JDeveloper Debugger Debugging through the source

10 - 4

Copyright 2008, Oracle. All rights reserved.

Using Logging and Diagnostics

Displaying debug messages to the console Java logging ADF logging / Oracle Diagnostic Logging (ODL)

10 - 5

Copyright 2008, Oracle. All rights reserved.

Displaying Debug Messages to the Console

Edit the projects run configuration:

Set Java options:


-Djbo.debugoutput=console

10 - 6

Copyright 2008, Oracle. All rights reserved.

Java Logging

It is useful in environments where you cant run the debugger or where running the debugger might hide the problem. Many Java programs use the Java logging API to produce useful messages. You can configure Java logging to produce different levels of logging output:
SEVERE WARNING INFO CONFIG FINE FINER FINEST ALL NONE

10 - 7

Copyright 2008, Oracle. All rights reserved.

Core Java Logging

Edit <Java_Home>/jre/lib/logging.properties:
Set java.util.logging.ConsoleHandler.level=FINE Add the line: com.sun.faces.level=FINE

Now the log contains JSF Reference Implementation debug messages.

10 - 9

Copyright 2008, Oracle. All rights reserved.

Using ADF Logging

ADF Logging is built on Oracle Diagnostic Logging (ODL), which provides:


Capture of context information Control over which messages are logged by setting:

Logging level Module filter

ODL uses a common format and repository for all components in the WebLogic Server.

10 - 10

Copyright 2008, Oracle. All rights reserved.

Configuring ADF Logging


The Oracle Diagnostic Logging (ODL) configuration file (logging.xml) controls the loggers under the oracle tree.
Set the logging threshold for the groups you are debugging (levels are SEVERE, WARNING, INFO, CONFIG, FINE, FINER, or FINEST):

ADFm logger settings: <logger name="oracle.adf" level="FINE"/> <logger name="oracle.jbo" level="FINE"/> ADFv logger settings: <logger name="oracle.adf" level="FINE"/> <logger name="oracle.adfinternal" level="FINE"/> ADFc logger settings: <logger name="oracle.adf.controller" level="FINE"/> <logger name="oracle.adfinternal.controller" level="FINE"/>

Optionally set the module filter.

10 - 11

Alternatively, create configuration in JDeveloper.


Copyright 2008, Oracle. All rights reserved.

Creating Logging Configurations in JDeveloper

ADF Model debugging configuration: Edit the projects run configuration. Set Java options: -Djbo.debugoutput=adflogger -Djbo.adflogger.level=FINE

10 - 13

Copyright 2008, Oracle. All rights reserved.

Viewing ODL Logs

10 - 14

Copyright 2008, Oracle. All rights reserved.

Using Design-Time Code Validation

JDevelopers editors provide error cues and correction suggestions for files such as: XML Java JSPX

10 - 15

Copyright 2008, Oracle. All rights reserved.

Design-Time XML Validation

10 - 16

Copyright 2008, Oracle. All rights reserved.

Design-Time Java Code Validation

10 - 17

Copyright 2008, Oracle. All rights reserved.

Design-Time JSPX Validation

As you edit a page, the XML syntax is checked and errors and warnings are flagged. Errors are visible in Design, Source and Bindings editors.

10 - 18

Copyright 2008, Oracle. All rights reserved.

Using Tools and Utilities

JUnit JDeveloper Profiler FileMon Web service sample client JDeveloper HTTP Analyzer JDeveloper Debugger

10 - 19

Copyright 2008, Oracle. All rights reserved.

Testing Java Code with JUnit

Open source regression testing framework Useful for creating tests to verify Java code JDevelopers JUnit extension provides wizards for creating test components. More information and examples:
SRDemo sample application Toystore sample application JDeveloper online documentation http://www.junit.org

10 - 20

Copyright 2008, Oracle. All rights reserved.

Unit Testing with JUnit

JUnit makes it easy for developers to write and run repeatable tests. Its features include: Assertions for testing expected results Test fixtures for sharing common test data Test suites for organizing and running tests Graphical and textual test runners

10 - 21

Copyright 2008, Oracle. All rights reserved.

Using JDevelopers Profiler

With the Profiler, you can: Monitor programs as they run Find bottlenecks and memory leaks Two types of profiling: CPU: Method processing times Memory: Allocation and freeing of data objects

10 - 22

Copyright 2008, Oracle. All rights reserved.

Running the Profiler

10 - 23

Copyright 2008, Oracle. All rights reserved.

Identifying Search Paths on Windows with FileMon


Useful for troubleshooting CLASSPATH problems Shows you the path that your running application is looking in for classes and files

10 - 24

Copyright 2008, Oracle. All rights reserved.

Troubleshooting Web Services

You can test Web services by: Defining a sample client Using the HTTP Analyzer

10 - 25

Copyright 2008, Oracle. All rights reserved.

Troubleshooting Web Services: Sample Client


The sample Java client initializes a proxy to the Web service. You add custom code to call the Web service operations.
greetingService_Service=new GreetingService_Service(); GreetingService greetingService = greetingService_Service.getGreetingServiceSoapHttpPort(); // Add your code to call the desired methods. System.out.println(greetingService.sayHelloTo("Pam"));


10 - 26

To create a sample client, select Create Client for Web Service Annotations in the context menu. It is not automatically synchronized with the Web service.
Copyright 2008, Oracle. All rights reserved.

Troubleshooting Web Services: HTTP Analyzer

10 - 27

Copyright 2008, Oracle. All rights reserved.

Using the JDeveloper Debugger

It is very useful for pinpointing problems in your application. Set source breakpoints to pinpoint problems in custom code. Set exception breakpoints to stop when a particular exception is thrown. When breakpoint is encountered at run time, you can step through code and view values of variables. To run an application in debug mode, right-click and select Debug.

10 - 28

Copyright 2008, Oracle. All rights reserved.

Understanding Breakpoint Types

Type
Exception

Breaks when
An exception of this class (or a subclass) is thrown. A particular source line in a particular class in a particular package is run. A method in a given class is invoked.

Source

Method

Class

Any method in a given class is invoked.

Watchpoint

A given field is accessed or modified.

10 - 29

Copyright 2008, Oracle. All rights reserved.

Using Breakpoints

You can create groups of breakpoints that can be enabled or disabled all at once. You can use conditional breakpoints. Examples:
value instanceof oracle.jbo.domain.Date status.equalsIgnoreCase("shipped") i > 50

You can use actions other than stop with breakpoints.

10 - 31

Copyright 2008, Oracle. All rights reserved.

Declarative UI Debugging
The Declarative Debugger enables you to set breakpoints on: Executables Task flow activities Bindings Breakpoint reached:

10 - 32

Copyright 2008, Oracle. All rights reserved.

Using the EL Evaluator

The expression language evaluator enables: Introspection of the values between the view and model Watches based on EL

Using the discovery function

An evaluated expression

An evaluated expression on watch list displays changed value.

10 - 33

Copyright 2008, Oracle. All rights reserved.

ADF Structure Pane and ADF Data Window

During debugging: ADF Structure Pane shows items in current viewport ADF Data Window shows data within:
Item selected in ADF Structure Pane ADF context Scoped variables

10 - 34

Copyright 2008, Oracle. All rights reserved.

Object Preferences

Filter out fields that are displayed in debugger. Change default value displayed in debugger. Show expressions as details instead of fields. Customize types throughout the type hierarchy.

10 - 35

Copyright 2008, Oracle. All rights reserved.

Using Oracle ADF Source Code for Debugging

Adding ADF source code enables you to: Access Javadocs in the code editor Set breakpoints on Oracle code as well as your own Access symbolic names via Debug libraries

10 - 36

Copyright 2008, Oracle. All rights reserved.

Setting Up Oracle ADF Source Code for Debugging


To use source code for debugging, you can: Add the source zip into the user library Add the library to a project

10 - 37

Copyright 2008, Oracle. All rights reserved.

Utilizing Quick Javadoc

Right-click a method and select Quick Javadoc:

10 - 38

Copyright 2008, Oracle. All rights reserved.

Setting Breakpoints in Source Code

To set a breakpoint in Oracle code, perform the following steps: 1. Press [Ctrl] + [-]. 2. Enter an Oracle ADF class name or its uppercase letters. 3. Set breakpoints in the source file that JDeveloper opens.

10 - 39

Copyright 2008, Oracle. All rights reserved.

Using Common Oracle ADF Breakpoints

Useful for debugging declarative functionality In oracle.jbo package you can set breakpoints on:
JboException DMLException uicli.binding.JUCtrlActionBinding.doIt() server.ViewObjectImpl. executeQueryForCollection() server.ViewRowImpl.setAttributeInternal() server.EntityImpl.setAttributeInternal()

10 - 40

Copyright 2008, Oracle. All rights reserved.

Debugging Interactions with the Model Layer

Controlled by two classes:


oracle.adf.controller.faces.lifecycle.FacesPageLifecycle oracle.adf.controller.v2.lifecycle.PageLifecycleImpl

Set breakpoints if encountering problems such as: Components not displaying correctly with complete data Validation errors not rendering properly

10 - 41

Copyright 2008, Oracle. All rights reserved.

Correcting Failures to Display Data

To debug all executables:


oracle.adf.model.binding.DCBindingContainer internalRefreshControl(int, boolean)

To debug the method iterator:


oracle.jbo.uicli.binding.JUMethodIteratorDef initSourceRSI()

To debug an attribute binding:


oracle.jbo.uicli.binding.JUCtrlValueBinding getInputValue()

10 - 42

Copyright 2008, Oracle. All rights reserved.

Correcting Failures to Invoke Actions and Methods


Actions are ignored if an executable or its target binding is not executed. You can debug action or method invocation by breaking on DCDataControl.invokeOperation(), which is entry point for action and method execution. You can debug invocation of coded methods by breaking on DCGenericDataControl.invokeOperation().

10 - 45

Copyright 2008, Oracle. All rights reserved.

Debugging Life Cycle Events: Task Flows

Before a task flow is called: oracle.adfinternal.controller.activity. TaskFlowCallActivityLogic.execute() Before a task flows input parameters are resolved: oracle.adfinternal.controller.activity. TaskFlowCallActivityLogic.getInputValues() Before and after a task flow returns: oracle.adfinternal.controller.activity. TaskFlowReturnActivityLogic.execute()

10 - 47

Copyright 2008, Oracle. All rights reserved.

Debugging Life Cycle Events: Parameters and Methods


For debugging the ADF controllers interpretation of the navigation routing: oracle.adfinternal.controller.engine. ControlFlowEngine.doRouting() For debugging before view activitys input parameters are evaluated: oracle.adfinternal.controller. application.PageParameterPagePhaseListener .beforePhase() For calling an ADF controller method action: oracle.adfinternal.controller.activity. MethodCallActivityLogic.execute()
Copyright 2008, Oracle. All rights reserved.

10 - 48

Debugging Life Cycle Events: Switching Between Main Page and Regions

To keep track of the context switching between the main page and regions, set a breakpoint in: oracle.adfinternal.controller.state. RequestState.setCurrentViewPortContext()

10 - 49

Copyright 2008, Oracle. All rights reserved.

Obtaining Help

Sources of help include: Online Help Javadoc Support (MetaLink) Forums Blogs Internet Search

10 - 50

Copyright 2008, Oracle. All rights reserved.

Requesting Help

Post your request to the appropriate forum: Use meaningful subject line. Describe exact steps to reproduce the problem. Include exact error information (error number, exception) if you receive an error message. Include a stack trace if appropriate. Include a test case if possible. List technologies and product version numbers. Concrete examples are better than abstract descriptions. Mention troubleshooting steps you have tried and how they affected the problem.
10 - 51

Copyright 2008, Oracle. All rights reserved.

Summary

In this lesson, you should have learned how to: Use tools for logging and diagnostics Utilize design-time code validation Make use of FileMon and JUnit Use the JDeveloper profiler Test Web service calls:
Use a sample client to call a Web service Use the JDeveloper HTTP Analyzer

Use the JDeveloper debugger Utilize sources of help

10 - 52

Copyright 2008, Oracle. All rights reserved.

Practice 10 Overview: Troubleshooting


This practice covers running the JDeveloper debugger to diagnose a problem with the ADF BC model.

10 - 53

Copyright 2008, Oracle. All rights reserved.

Potrebbero piacerti anche