Class RollbackWebApplicationException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
jakarta.ws.rs.WebApplicationException
org.keycloak.services.RollbackWebApplicationException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CorsErrorResponseException, ErrorPageException, ErrorResponseException

public abstract class RollbackWebApplicationException extends jakarta.ws.rs.WebApplicationException
Base class for all Keycloak error exceptions that should roll back the current transaction.

Calling getResponse() with a non-null result (containing an entity) leads to RESTEasy directly returning that response instead of propagating the exception to KeycloakErrorHandler.toResponse(Throwable), which would normally ensure rollback. This base class ensures setRollbackOnly() is always called before the error response is returned.

Subclasses must override createErrorResponse() instead of getResponse().

See Also:
  • Constructor Details

    • RollbackWebApplicationException

      protected RollbackWebApplicationException(String message, jakarta.ws.rs.core.Response.Status status)
    • RollbackWebApplicationException

      protected RollbackWebApplicationException(String message, jakarta.ws.rs.core.Response response)
    • RollbackWebApplicationException

      protected RollbackWebApplicationException(Throwable cause, jakarta.ws.rs.core.Response response)
  • Method Details

    • getResponse

      public final jakarta.ws.rs.core.Response getResponse()
      Overrides:
      getResponse in class jakarta.ws.rs.WebApplicationException
    • getOriginalResponse

      protected jakarta.ws.rs.core.Response getOriginalResponse()
    • createErrorResponse

      public jakarta.ws.rs.core.Response createErrorResponse()
      Builds the error response. Override this instead of getResponse().