Oracle ADF Architecture TV - Development - Error Handling
-
Upload
chris-muir -
Category
Technology
-
view
455 -
download
6
description
Transcript of Oracle ADF Architecture TV - Development - Error Handling
![Page 1: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/1.jpg)
1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
![Page 2: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/2.jpg)
2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Real World ADF Design & Architecture Principles Error Handling
ORACLE PRODUCT
LOGO
15th Feb 2013 v1.0
![Page 3: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/3.jpg)
3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Learning Objectives
• At the end of this module you should be able to:
– Understand the ADF error handling architecture – Know the scope of an error handler – Distinguish between error handling and incident reporting
Image: imagerymajestic/ FreeDigitalPhotos.net
![Page 4: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/4.jpg)
4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 5: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/5.jpg)
5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Fiction …
Wouldn't it be good if there was a single location to handle all application errors and exceptions?
![Page 6: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/6.jpg)
6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
… and Fact.
Not perfect, but a solution.
![Page 7: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/7.jpg)
7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 8: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/8.jpg)
8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ADF Error Handling Hooks - Overview
ADF Faces (ADFv)
EJB/JPA ADF Business Components Java
ADF Model (ADFm)
JAX-WS
Unhandled exceptions
Servlet Container U
nhan
dled
exc
eptio
ns
Render Response
Propagates exceptions
ADF Controller (ADFc)
Business Service Layer
ADF Binding Layer Data Control
![Page 9: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/9.jpg)
9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ADF Exception Handlers
• ADFm Exception Handler – Error Handler (DCErrorHandler) in BindingContext
• ADFc Exception Handler – Exception Handler activity in Task-Flow – Application wide Exception Handler
• ADFv Exception Handler – oracle.adf.view.rich.context.ExceptionHandler
• Container, error-page in web.xml
![Page 10: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/10.jpg)
10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ADF Error Handling Overview ADF Interaction in JSF Request Lifecycle
EJB/JPA ADF Business Components Java
ADF Binding
JAX-WS
Restore View
Apply Request
Process Validation Update Model
Invoke Action
Render Response 1
2
3
4
5
6
JSF
![Page 11: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/11.jpg)
11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 12: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/12.jpg)
12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
oracle.jbo.JboException
• JboException extends java.lang.RuntimeException – Thus Business Component method can throw exceptions without
a throws clause in the method signature • Translation of error messages occur by the client calling getLocalizedMessage() and not when an error is thrown
One Exception Super Class for All Exceptions
![Page 13: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/13.jpg)
13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Bundled Exception Mode
• Enabled by default • Presents maximal set of failed validation exceptions • Java supports single exception to be thrown at a time • ADF BC moves all exceptions under a parent exception
– Multiple entity attribute validation errors (ValidationException) are wrapped in RowValException parent exception
– Multiple rows that fail validation performed during commit will have the RowValException wrapped in TxnValException object
– You can recursively introspect exception by calling getDetails() on each exception
All Exceptions at Once
![Page 14: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/14.jpg)
14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Exceptions that are not handled in the business service propagate to the ADF model layer.
Image: Ambro/ FreeDigitalPhotos.net
![Page 15: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/15.jpg)
15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 16: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/16.jpg)
16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ADF Model Error Handler
• The ADF model error handler deals with – All ADF binding errors – Business service errors that occur when accessing a service
trough the ADF binding layer • Formats and displays error message • Default error handler skips the top-level JboException because it
only is a bundled exception wrapper for other business exceptions
![Page 17: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/17.jpg)
17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Creating A Custom Error Handler
• Extend oracle.adf.model.binding.DCErrorHandlerImpl and configure your custom error error handler in DataBindings.cpx
• Override the following methods as needed – reportException
• Override this method to analyze exceptions for errors you want to handle – getDisplayMessage
• Override to change or suppress (null value) the displayed message – getDetailedDisplayMessage
• Override this method to provide HTML markup formatted detail information – skipException(Exception ex)
• Called by the framework to check if an exception should be ignored
![Page 18: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/18.jpg)
18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Oracle JDeveloper 11g R2
![Page 19: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/19.jpg)
19 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Custom Error Handler Example Skip Exception for SQL Exceptions
public class CustomErrorHandler extends DCErrorHandlerImpl { ... protected boolean skipException(Exception ex) { if (ex instanceof DMLConstraintException) { return false; //don't show details of SQL exception } else if (ex instanceof SQLException) { return true; } else { return super.skipException(ex); } } )
![Page 20: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/20.jpg)
20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Skip Exception Example SQLIntegrityConstraintViolationException
skipException == false skipException == true
![Page 21: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/21.jpg)
21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The code is from a managed bean in our application. What happens in case of an
exception?
Image: imagerymajestic/ FreeDigitalPhotos.net
OperationBinding operationBinding = null; operationBinding = getOperationBinding("UpdateOrder"); operationBinding.execute(); …
![Page 22: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/22.jpg)
22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
On a Related Note
• It happens quite often that developers execute a client method directly on the Application Module – BindingContext > findDataControl("...") > getDataProvider() – Cast data provider to Application Module interface – Execute client methods on it
• The risk is that – Exceptions thrown by the client interface logic are not handled by the
ADFm error handler if invoked directly – Inconsistent error handling may occur
![Page 23: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/23.jpg)
23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 24: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/24.jpg)
24 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 24 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The ADF controller handles exceptions that occur during task flow execution
Image: Ambro/ FreeDigitalPhotos.net
![Page 25: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/25.jpg)
25 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ADF Controller Exception Handling
• Exceptions that may occur during task flow execution include – Method call activity that throws an exception – Task flow initialize or finalize methods throwing an exception – Authorization failures when accessing an activity
• Controller exceptions are handled by a task flow activity that is designated as an exception handler
• When a task flow throws an exception, control flow is passed to the designated exception handling activity
Introduction
![Page 26: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/26.jpg)
26 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Exception Handler Activity How-to Define an Activity as the Exception Handler
![Page 27: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/27.jpg)
27 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Example: Method Error Handler
public void showErrorDialog() { ControllerContext context = ControllerContext.getInstance(); ViewPortContext currentViewPort = context.getCurrentViewPort(); if (currentViewPort.isExceptionPresent()) { FacesMessage fm = new FacesMessage( FacesMessage.SEVERITY_WARN, "Application Error", currentViewPort.getExceptionData().getMessage()); FacesContext fctx = FacesContext.getCurrentInstance(); fctx.addMessage("ApplicationInfo", fm); fctx.renderResponse(); } }
![Page 28: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/28.jpg)
28 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ADF Controller
• Exceptions that occur in context of task flow are forwarded to exception handler activity
• Best Practices - Define exception handling activity in each bounded and unbounded task flows
• Define exception handler in task flow template for consistency
Exception Handler Activity
![Page 29: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/29.jpg)
29 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ADF Controller
• AdfcExceptionHandler is the ADF controller internal framework class that passes control to the task flow's designated exception handler activity
• If no exception handler activity exists, the control is passed the browser
• Default exception handler does not handle exceptions thrown during RENDER_RESPONSE phase
Default Exception Handling
![Page 30: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/30.jpg)
30 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Customizing the Framework Error Handling
• Configuration – Create oracle.adf.view.rich.context.ExceptionHandler
text file and store it in .adf\META-INF\services – you need to create the “services” folder – Add the absolute name of your custom exception handler
• Java class that extends ExceptionHandler
• Configured for whole ADF application – Deployed in EAR file
Add Your Own Exception Handler
![Page 31: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/31.jpg)
31 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
import oracle.adf.view.rich.context.ExceptionHandler; public class CustomExceptionHandler extends ExceptionHandler { public CustomExceptionHandler() { super(); } public void handleException(FacesContext facesContext, Throwable throwable, PhaseId phaseId) throws Throwable{ if ( … Exception or Error to check …){ //handle issue } else { //pass error to default exception handler throw throwable; } } }
ADF Controller Overriding Default Exception Handler Class
![Page 32: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/32.jpg)
32 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 32 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Be thoughtful. Don't override the framework exception handler to eagerly or for no reason. Keep in mind that the error handler is not deployed with bounded task flows but deployed with the application.
Image: Ambro/ FreeDigitalPhotos.net
![Page 33: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/33.jpg)
33 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Log Exceptions, Report Exceptions ..
• Exception handler activities handle exceptions but don't report them – No programming error fixes itself – Log and report programming or system errors
• Implement a exception handling, logging and reporting strategy that can be reused and that is declaratively applied
• Report serious issues – Considers weekends and vacations
• Evaluate BPM (SOA Suite) Human Workflow integration – In case of emergency, send mail or SMS
![Page 34: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/34.jpg)
34 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 35: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/35.jpg)
35 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
What Could Happen Task Flow Exception Propagation
Memory Stack
Current Task Flow
Task Flow 4
Task Flow 3
Task Flow 2
Task Flow 1
Task Flow 2 Call
Task Flow 3 Call
Task Flow 4 Call
!
!
View1
View2
View3
View4
Task Flow 1
Task Flow 2
Task Flow 3
Task Flow 4
EH
EH
Method Call
Current Task Flow
BANG!
![Page 36: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/36.jpg)
36 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
What Could Happen Task Flow Exception Propagation
Memory Stack
Current Task Flow
Task Flow 2
Task Flow 1
Task Flow 2 Call
Task Flow 3 Call
Task Flow 4 Call
Propagate Exception
Propagate Exception
!
!
View1
View2
View3
View4
Task Flow 1
Task Flow 2
Task Flow 3
Task Flow 4
EH
EH
Current Task Flow
Method Call
BANG!
![Page 37: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/37.jpg)
37 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
What Could Happen Task Flow Exception Propagation
!
!
View1
View2
Task Flow 1
Task Flow 2
EH
EH
Memory Stack
Current Task Flow
Task Flow 2
Task Flow 1
Task Flow 2 Call
![Page 38: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/38.jpg)
38 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Visual Example Exception Handler in Caller Task Flow
BANG!
!
![Page 39: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/39.jpg)
39 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Visual Example Exception Handler in Top Level Task Flow
BANG!
!
![Page 40: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/40.jpg)
40 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 40 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Every bounded task flow should have an error handler activity defined. Task flow templates help to configure error handlers consistent throughout an application.
Image: Ambro/ FreeDigitalPhotos.net
![Page 41: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/41.jpg)
41 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 42: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/42.jpg)
42 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Unbounded Task Flow
• There always is a single unbounded task flow instance available for an application – Independent of the number of adfc-config.xml files available in the
application class path • Unbounded task flows cannot be based on task flow templates
Exception Handling Strategy
![Page 43: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/43.jpg)
43 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Unbounded Task Flow
• To build "error handling templates" for unbounded task flows you use an unbounded task flow definitions in an ADF Library – Keep adfc-config.xml as the unbounded task flow definition file – Deploy error handling logic as managed bean within ADF library – Load order of unbounded configuration files determines which
exception handler become active in cases of multiple defined handlers
– ADFc configuration files on the class path precede configurations in the application
Exception Handling Strategy
![Page 44: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/44.jpg)
44 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 45: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/45.jpg)
45 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Exception Handling • Typically, view layer exceptions occur because of
– Failed execution of client logic in managed beans – Failed access to the ADF binding layer
• EL references in page source • Java references in managed beans
– Failed EL expressions • Typos in the object name • Missing objects (e.g. entity object references) • Failed type casting (e.g. oracle.jbo.domain.Number to Long)
– Expired session
![Page 46: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/46.jpg)
46 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Exception Raised In Managed Bean Example: Simulating A Problem
![Page 47: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/47.jpg)
47 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Exception Raised In Managed Bean Solution: Routing Exception To Binding Layer
![Page 48: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/48.jpg)
48 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 49: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/49.jpg)
49 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Servlet Container
• Handles all exceptions not handled by an application – Available to all Java EE applications
• Looks in web.xml file for directive on how to handle a specific error code or the exception type
• If nothing is set-up in web.xml, the exception terminates the user application session – In Java, a stack trace is displayed in the browser, which exactly
what you don't want to happen
![Page 50: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/50.jpg)
50 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Java EE Exception Handling Last Resort
<error-page> <error-code> … http error code here (e.g 404)… </error-code> <location>/unhandled_error_page.html</location> </error-page> <error-page> <exception-type> … exception class here … (e.g. java.lang.Throwable) </exception-type> <location>/unhandled_exception_page.html</location> </error-page>
![Page 51: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/51.jpg)
51 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Program Agenda • Error Handling Introduction • Handling ADF Lifecycle Errors • ADF Business Components • ADF Binding Layer • ADF Controller
– Bounded Task Flow – Unbounded Task Flow
• ADF View • Servlet Container • Summary
![Page 52: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/52.jpg)
52 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
ADF Error Handling Summary Error Handling by Architecture Layers
• try-catch block
• ADFm Error Handler
• Exception Handler Activity • Custom ADFc Exception Handler
• try-catch block
• web.xml
ADF Faces
EJB/JPA ADF Business Components Java
ADF Model
JAX-WS
Unhandled exceptions
Servlet Container
Unh
andl
ed e
xcep
tions
Render Response
Propagates exceptions
ADF Controller
![Page 53: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/53.jpg)
53 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Conclusion
• Anticipate problems and work on a mitigation strategy – Only leave unexpected errors and errors you
want for pass through unhandled for the handlers – Like for application security, perform a risk
analysis and identify threats (database down, WS not responsive, NPE …)
• Define exception handling strategies and code them into custom standard exception handler classes
• Log errors by severity
![Page 54: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/54.jpg)
54 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Conclusion
• Access business service methods through the binding layer
• Use try/catch blocks in any managed bean method – Route managed bean exceptions to the binding layer
reportError() method • Use custom task flow exception handler thoughful
– .adf\META-INF\services – Avoid new exceptions in your exception handler – Keep in mind that this exception handler is on an
application level and not task flow / ADF library level
![Page 55: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/55.jpg)
55 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Further Reading
• Oracle Magazine Article "Catch Me If You Can" – http://www.oracle.com/technetwork/issue-archive/2013/13-mar/
o23adf-1897193.html
• Oracle JDeveloper and ADF Documentation Library – Fusion Developer Guide
• "Handling and Displaying Exceptions in an ADF Application" • "Customizing Business Components Error Messages"
• How to log all errors to the database – http://one-size-doesnt-fit-all.blogspot.de/2008/06/jdev-adf-how-to-log-all-
errors-to.html
![Page 56: Oracle ADF Architecture TV - Development - Error Handling](https://reader034.fdocuments.us/reader034/viewer/2022051513/5461e985b1af9f71408b4d8a/html5/thumbnails/56.jpg)
56 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.