Post on 13-Nov-2014
19Copyright © 2007, Oracle. All rights reserved.
Troubleshooting
19-2 Copyright © 2007, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:
• Use JDeveloper and Application Development Framework (ADF) tools for logging and diagnostics
• Test a business service in isolation from views or controllers
• Make use of FileMon, JUnit, and Http Analyzer
19-3 Copyright © 2007, Oracle. All rights reserved.
Troubleshooting Basics
• Diagnose the problem.
• Request help.
• Create a test case.
19-4 Copyright © 2007, Oracle. All rights reserved.
Diagnosing the Problem
• Find out where it occurs:– Test the database query and the business services
layer.– Read any exceptions and stack traces.– Set breakpoints in the custom code.
• Examine logs and diagnostic output.
• Strip away complexity.
• Search for similar problems: Google, WebIV, bug.
19-5 Copyright © 2007, Oracle. All rights reserved.
Requesting Help
Post a topic on the JDeveloper OTN Forum:
• Describe exact steps to reproduce the problem.
• Include a test case, if possible.
• List technologies and product version numbers.
• Provide concrete examples rather than abstract descriptions.
• Include a stack trace, if appropriate.
• Mention troubleshooting steps you have tried and how they affected the problem.
19-6 Copyright © 2007, Oracle. All rights reserved.
Creating Test Cases
Create the simplest possible application that reproduces the problem:
• Database schema: Use a standard schema, if possible.
• Business service: Remove components and customization.
• Client: Try Business Components (BC) tester, sample client, or basic ADF client.
• Deployment: Try embedded or stand-alone Oracle Application Server Containers for Java EE (OC4J) rather than Application Server.
19-7 Copyright © 2007, Oracle. All rights reserved.
Logging and Diagnostics
• Java logging
• ADF Logger
• ADF Diagnostics
19-8 Copyright © 2007, Oracle. All rights reserved.
Java Logging
• Useful for tracing EL evaluation in JavaServer Faces (com.sun.faces).
• 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
19-9 Copyright © 2007, Oracle. All rights reserved.
Configuring Java Logging
• Configure logging in <jdk_path>\jre\lib\logging.properties.
• Useful settings:– Where to send the output. For example:
– Logging level for different packages. For example:
– Level of messages to a particular output. For example:
com.sun.faces.el.level = FINE
java.util.logging.ConsoleHandler.level = INFO
handlers= java.util.logging.ConsoleHandler
19-10 Copyright © 2007, Oracle. All rights reserved.
Sending Logger Output to a File
• Set handlers to FileHandler. For example, send output to the console and to a file:
• The log output file is created in your user.home directory.
• File name is java<n>.log (java0.log, java1.log, and so on).
handlers= java.util.logging.ConsoleHandler, java.util.logging.FileHandler
19-11 Copyright © 2007, Oracle. All rights reserved.
ADF Logger
• ADF classes use the ADF Logger.
• Configuration file, embedded OC4J:– <jdev_home>\jdev\system\oracle.j2ee.xxxxx
\embedded-oc4j\config\j2ee-logging.xml
• Configuration file, stand-alone OC4J:– <oc4j_root>\j2ee\home\config\j2ee-
logging.xml• Contains entries for the different ADF packages:
<logger name="oracle.adf" level="INFO"/> <logger name="oracle.adf.faces" level="INFO"/><logger name="oracle.adf.controller" level="INFO"/><logger name="oracle.bc4j" level="INFO"/>
19-12 Copyright © 2007, Oracle. All rights reserved.
Using ADF Diagnostics
• Particularly useful for verifying ADF BC SQL statements.
• Outputs detailed information, including:– SQL statements– JDBC connection– Database locks– Configuration property settings– Object creation
• Available in JDeveloper or on the command line
19-13 Copyright © 2007, Oracle. All rights reserved.
Turning on Diagnostics in JDeveloper
19-14 Copyright © 2007, Oracle. All rights reserved.
Turning on Diagnostics in OC4J
• Stand-alone OC4J: Start OC4J with the diagnostics option. For example:java –Djbo.debugoutput=console –jar oc4j.jar
• Embedded OC4J:– Shut down the embedded OC4J.– Set the Java option in your client project’s
properties.
• To send diagnostics output to the OC4J logger:– java –Djbo.debugoutput=ADFLogger –jar
oc4j.jar– View the diagnostics on the Log page of
Application Server Control.
19-15 Copyright © 2007, Oracle. All rights reserved.
Sample Java Clients
• Sample Java clients are useful for testing your business service.
• You can quickly create a sample client for a Web service from the Applications Navigator context menu.
• The client is a generated Java class with code to test your service.
• Client code is not automatically synchronized with changes to your service. You must create a new sample client when you make changes.
19-16 Copyright © 2007, Oracle. All rights reserved.
Sample Client for Web Service
• The sample client initializes a proxy to the Web service.
• You add custom code to call the Web service operations.
• To create a sample client, select Generate Web Service Proxy in the shortcut menu.
ws.SimpleWebServiceSoapHttpPortClient myPort = new ws.SimpleWebServiceSoapHttpPortClient();System.out.println("calling " + myPort.getEndpoint());// Add your own code hereSystem.out.println(myPort.sampleMethod(“hello”));
19-17 Copyright © 2007, Oracle. All rights reserved.
Tools and Utilities
• FileMon
• JUnit
• Http Analyzer
• JDeveloper Debugger
19-18 Copyright © 2007, Oracle. All rights reserved.
Identifying Search Paths with FileMon
• Useful for troubleshooting CLASSPATH problems
• Shows you the path that your running application is looking in for classes and files
19-19 Copyright © 2007, Oracle. All rights reserved.
Testing Java Code with JUnit
• JUnit is an open-source regression testing framework.
• It is useful for creating tests to verify Java code.
• JDeveloper’s 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
19-20 Copyright © 2007, Oracle. All rights reserved.
Analyzing HTTP Requests
The Http Analyzer:
• Shows the content of HTTP request and response packets
• Is useful for monitoring Web services
19-21 Copyright © 2007, Oracle. All rights reserved.
Debugging with JDeveloper
• JDeveloper Debugger is 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 a breakpoint is encountered at run time, you can step through code and view values of variables.
• To run a file in debug mode, right-click and select Debug.
19-23 Copyright © 2007, Oracle. All rights reserved.
Summary
In this lesson, you should have learned how to:
• Diagnose problems, request help, and create test cases to solve a problem in your application
• Use Java and ADF logging, and ADF diagnostics to track down an error
• Create sample clients to eliminate client issues
• Use FileMon, JUnit, Http Analyzer, and JDeveloper Debugger to track down a problem