Before closing transaction, you must commit or rollback it first.

Change 'catch Exception' to 'catch Throwable'