My Oracle Support Banner

How To Customize Exception Handlers In An ADF REST DC Application? (Doc ID 2877145.1)

Last updated on AUGUST 01, 2023

Applies to:

Oracle JDeveloper - Version 12.2.1.4.0 to 12.2.1.4.0 [Release 12c]
Information in this document applies to any platform.

Goal

According to unpublished

 Bug 34270830 - NO ERROR DETAILS IN REST CALL RESPONSE WHEN USING REST FRAMEWORK VERSION 4

and to

Oracle® Fusion Middleware Developing Fusion Web Applications with Oracle Application Development Framework 12c (12.2.1.4.0) - What You May Need to Know About Versioning the ADF REST Framework

starting from ADF 12.2.1.4.0, if the invoke of a REST endpoint exposed by an ADF REST DC application ends up with a 500 error, no error details are sent over and the response body will be empty.

Differently, if the invoke ends with a 400 error code, then the error details are sent over.

The change is due to the fact that sending details in 500 errors may expose to security treats, as explained in unpublished

 Bug 33942808 - SERVER ERRORS FROM REST CALLS NOT CONTAINED IN RESPONSE OF MIGRATED APPLICATION 

When creating an ADF DC REST application, JDeveloper does all the magic and there is no need to write any code when creating REST endpoints on top of Entity Objects persisted in a DataBase.

However, if a DataBase error occurs for whatever reason, including application's business logic (e.g. duplicate entry, custom DB errors raised from Stored Procedures), that will cause an exception (i.e. SQLException) to be raised and flow in the J2EE container as an unchecked exception, with the consequence that it will be interpreted as an internal error causing also the generation of an error response with 500 error code and without details.

This means that the REST endpoint clients will not be aware there was actually a business logic violation error instead of a true system error.

How to intercept these situations at application side and send custom 400 error response in the scenario described above?

In the specific, how to wrap DML exceptions raised from persistence layer into custom exceptions?

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.