I have a question related to ADF exception handling.
Imagine a button on a ADF jspx page which has a binding to a Application Module method. If the AM method throws a Null Pointer Exception, the normal behavior we notice is that
error message is shown in a pop up to the user.
Our application requirements is that we need to redirect the user to a global error page with a message to contact help desk for any unexpected error.
My question is how to we redirect user to a error page if any unexpected errors occurs in Model project/AM instead of exposing the error to the client in a popup.
Always mention your JDev version.
Are you using taskflows? If yes, you can use Taskflow Exception Handler : Check this out : Andrejus Baranovskis's Blog: Exception Handler for Method Calls inside ADF Task Flows with Pages
The jdeveloper version I am using is 126.96.36.199.
The method explained in the below blog only works for method call activities in the task flow.
But if I have a task flow --> the fragment inside the task flow has a button that calls a AM method and that methods throws NullPointerException, then the task flow
Exception Handler is not invoked.
Any error that occurs inside the app module method, it is being converted to a Faces Message and displayed to the user. In the case I told user will see
NullPointerException in a pop up.
Our application use case is, any unexpected error should take the user to a global error page. While it is easy to do this for controller layer exceptions, the Model layer
exceptions always shows in a pop up.
The link you gave was helpful.
I did the following:
1) We Created a Class that extends DCErrorHandlerImpl to handle the model exceptions. In the reportException, we check if the errors can be handled by app, if not we re throw the exception.
throw (NullPointerException)e.getCause(); // Inside the report Exception Method..
2) The exception gets propagated to the Controller layer. We have written a class that extends oracle.adf.view.rich.context.ExceptionHandler. Inside the exception handler class, we check if exception occurred in RENDER_RESPONSE phase, if yes, we do a java script redirect to error page. For any other phase, we rethrow the exception.
3) The exceptions that are re thrown from the ExceptionHandler class are propagated to the method exception handler defined in adfc-config.xml and finally user is redirected to a error page.
The above approach works fine for different scenarios.
But only in case of a bounded task flow running as a region, step 3 does not work fine.
After step2, we see the following in console and user see a java script popup. The exception does not get propagated to the method handler in the adfc-config.xml.
I did not really understand why the exception does not reach the method call activity in adfc.
<LifecycleImpl> <_handleException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase INVOKE_APPLICATION 5
In Frank's article:"
It was mentioned that "When you simulate an exception in the bounded task flow by clicking ADFc Custom Exception below the employee table, the error displays in the custom dialog box. The error handling, however, is not in the bounded task flow but in the unbounded task flow, which means that the bounded task flow is left in an unpredictable state, because application focus now is on the unbounded task flow"
What is the meaning of Unpredictable state here? Since our application requirement is to have a global error page we did not define exception handler in bounded task flows . All the exceptions are handled by exception handler of unbounded task flow.
Will that cause any issues?
Think about it this way: the user sees your bounded task flow, but the error it's down in the parent unbounded task flow. Now the problem is that the user e.g. clicks on a button (after he clicked the error message) in the bounded
task flow, which might not work as expected as the navigation it's broken due to the error before.