Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What is ProblemDetail in Spring Framework 6, which standard does it follow, and how do you enable it in Spring Boot?

ProblemDetail is Spring Framework 6's class for the problem details format of RFC 9457, which replaced RFC 7807. It has the standard fields type, title, status, detail and instance plus any custom properties, and it is sent with the media type application/problem+json. In Spring Boot we enable it for Spring MVC's own exceptions with spring.mvc.problemdetails.enabled=true, and ErrorResponseException and ResponseEntityExceptionHandler help us produce it for our own errors.

Why this question is asked

Before Spring Framework 6, every project invented its own error body: one had code and message, another error and description, a third a list of strings. Clients and API gateways had to learn each shape. RFC 9457 defines a standard shape for HTTP API errors, and Spring now supports it out of the box, so there is little reason to invent our own. Interviewers ask this concept question because ProblemDetail is the expected answer to how do you format errors in a modern Spring service, and the details, the fields, the media type and how Boot switches it on, show whether we have actually used it. In this answer, we will recap the standard, look at the fields, see Spring's classes, and then enable it in Spring Boot.

1A Quick Recap of the Problem Details Standard

RFC 7807, published in 2016, defined problem details for HTTP APIs: a small JSON (or XML) object that describes an error in a way both machines and people can read. In 2023 RFC 9457 replaced it. The new RFC keeps the same fields and media types, so a 7807 body is still valid, and it clarifies a few points, such as how to use extension fields, how to represent several problems of the same type, and a registry of common problem types.

The idea is simple. The HTTP status code already says what class of error happened. The problem details body adds the specifics in a predictable place, so a client can write one error parser for every API that follows the standard.

2The Fields of a Problem Detail

The standard defines five members, all optional, and allows any number of extension members next to them.

YAML
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
{
"type": "https://errors.example.com/order-not-found",
"title": "Order not found",
"status": 404,
"detail": "Order 42 was not found.",
"instance": "/orders/42",
"orderId": 42
}
Problem detail members
MemberMeaningExample
typeURI naming the kind of problemhttps://errors.example.com/order-not-found
titleshort summary, same for every occurrenceOrder not found
statusthe HTTP status code404
detailexplanation of this occurrenceOrder 42 was not found.
instanceURI of this occurrence/orders/42
extensionsany extra membersorderId, code, traceId, errors

type is a URI that identifies the kind of problem, ideally a page documenting it; when it is absent it means about:blank, which says the problem is no more specific than the status code, and then the title should be the status phrase. title is a short human summary that stays the same for every occurrence of that type. status repeats the HTTP status code for convenience. detail explains this particular occurrence. instance is a URI for this occurrence, often the request path. Anything else, like orderId here, is an extension member that clients may use and must ignore if they do not know it.

3The Media Type application/problem+json

A problem details body is sent with Content-Type application/problem+json, or application/problem+xml for the XML form. The distinct media type lets a client recognise a standard error without inspecting the body, for example a generic HTTP client can turn any problem+json response into a typed exception. Spring sets this content type automatically when a controller or handler returns a ProblemDetail, as long as the client accepts JSON.

4Spring's Classes: ProblemDetail, ErrorResponse and Friends

Spring Framework 6 added the ProblemDetail class, a simple container with setters for the five members and setProperty for extensions, which Spring's Jackson support writes as top-level fields. Around it are a few helpers. ErrorResponse is an interface for exceptions that know their own status, headers and ProblemDetail body; all of Spring MVC's own exceptions implement it. ErrorResponseException is a ready-made exception implementing ErrorResponse that we can throw or extend. ResponseEntityExceptionHandler is a base class for a @ControllerAdvice that handles all of Spring MVC's exceptions and renders their ProblemDetail.

Java
// Throwing an ErrorResponseException: Spring renders its ProblemDetail, no handler needed
public class OrderNotFoundException extends ErrorResponseException {
public OrderNotFoundException(long id) {
super(HttpStatus.NOT_FOUND, asProblem(id), null);
}
private static ProblemDetail asProblem(long id) {
ProblemDetail pd = ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, "Order " + id + " was not found.");
pd.setType(URI.create("https://errors.example.com/order-not-found"));
pd.setTitle("Order not found");
pd.setProperty("orderId", id);
return pd;
}
}
// throw new OrderNotFoundException(42) -> 404, application/problem+json, body as above

Notice that the exception carries its own response. For this to be rendered as ProblemDetail, it must be handled by something that understands ErrorResponse, which is exactly what ResponseEntityExceptionHandler, and the advice Spring Boot registers, do.

5Enabling It in Spring Boot

Without any configuration, Spring MVC's own exceptions, such as a 405 for a wrong method or a 400 for unreadable JSON, are resolved by calling sendError, and Spring Boot's /error page renders them in its older JSON shape. Setting one property changes that.

Properties
# application.properties
spring.mvc.problemdetails.enabled=true
# Before: POST /orders with broken JSON
# 400 {"timestamp": "...", "status": 400, "error": "Bad Request", "path": "/orders"}
# After:
# 400 application/problem+json
# {"type": "about:blank", "title": "Bad Request", "status": 400,
# "detail": "Failed to read request", "instance": "/orders"}

The property makes Boot register an advice that extends ResponseEntityExceptionHandler, so all standard exceptions and every ErrorResponseException are answered with ProblemDetail. If our application already defines its own advice extending ResponseEntityExceptionHandler, Boot's backs off, and our subclass takes over the same job. For WebFlux the property is spring.webflux.problemdetails.enabled. Check your Boot version, since defaults in this area may change between major versions.

6Follow-up questions

Does the property also change the /error page?

No. It affects exceptions resolved inside Spring MVC. Errors that reach the container, such as exceptions thrown in servlet filters, are still rendered by BasicErrorController with ErrorAttributes. To make those match, we customise ErrorAttributes or provide our own error controller.

Should every error use type about:blank?

about:blank is fine for generic errors like a 405, where the status says everything. For domain errors, a real type URI such as https://errors.example.com/duplicate-order is better, because it gives clients a stable identifier and a place to read documentation. Many teams also add a short code extension for easy matching.

How do we add a field such as traceId to every ProblemDetail?

In an advice extending ResponseEntityExceptionHandler, we override handleExceptionInternal, which every handled exception passes through, and call setProperty on the ProblemDetail body before returning. For ProblemDetails returned directly by our own handlers, we build them through one shared factory method that adds the same field.

7Conclusion

In this answer, we saw that ProblemDetail is Spring's representation of RFC 9457 problem details, the successor of RFC 7807. It holds type, title, status, detail and instance plus extension properties, and it is sent as application/problem+json. ErrorResponse, ErrorResponseException and ResponseEntityExceptionHandler let Spring's own exceptions and ours produce it, and in Spring Boot the property spring.mvc.problemdetails.enabled=true turns it on for the standard Spring MVC exceptions.

What to say in the interviewAbout 80 seconds aloud

Open with

ProblemDetail is Spring Framework 6's class for the problem details format from RFC 9457, which replaced RFC 7807 in 2023 and kept the same fields. It's a standard JSON body for HTTP API errors with five members: type, a URI identifying the kind of problem, defaulting to about:blank; title, a short summary that's the same for every occurrence; status, the HTTP code; detail, the explanation of this occurrence; and instance, usually the request path.

Then, if they want more

Anything else, like an orderId, code or traceId, is an extension member, which Spring writes at the top level when I call setProperty. The media type is application/problem+json, so clients can recognise a standard error just from the header.

Around it, Spring has the ErrorResponse interface, which all Spring MVC exceptions implement, ErrorResponseException, which I can throw or extend to carry my own ProblemDetail, and ResponseEntityExceptionHandler, a base class for an advice that renders all the standard exceptions as ProblemDetail.

In Spring Boot I enable it with spring.mvc.problemdetails.enabled=true, which registers such an advice, so errors like a 405 or unreadable JSON come back as problem+json instead of Boot's older error JSON. If I write my own subclass of ResponseEntityExceptionHandler, Boot's backs off. Filter errors still go through /error, so I'd align that separately.

About this answer

Last updated
12 November 2026
Versions it names
Spring Framework 6
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is ProblemDetail in Spring Framework 6, which standard does it follow, and how do...": https://scrivio-interview-library.netlify.app/spring-boot/error-handling/26ff6fe803/