This is not an uncommon use case: the transaction failed and we want to roll it back, but we would still like to update some monitoring database table with the error cause.
For doing this in a Spring application use REQUIRES_NEW propagation of the @Transactional annotation.
For doing this, create an application state tracking service, and annotate it with REQUIRES_NEW transaction propagation.
Each method in the state tracking service will run in it's own separate transaction, so when the transaction on the main business method rolls back, the state tracking information will still be available on the database.