OutOfMemoryError causes commit of JPA transaction

386 Views Asked by At

When my system gets "OutOfMemoryError: Java heap space", it commits the transaction (marked with org.apache.deltaspike.jpa.api.transaction.Transactional annotation).

How to avoid this and make a rollback instead? "Regular" exceptions do cause the rollback.

My JPA implementation is EclipseLink 2.6.4 and container is Tomcat 8.5.33 running with Java 8.

1

There are 1 best solutions below

0
On

I solved it by catching OutOfMemoryError and rethrowing it as RuntimeException. This produced proper rollback, garbage collection (because big object graph was released) and service could continue running.