Failure while notifying an observer of event null - when trying to fire event on transaction failure

Viewed 401

I need possibility to be informed when transaction has failed. And for that case I did create Event observer:

    public class TransactionObserver {

        private static final Logger log = Logger.getLogger(TransactionObserver.class);

        @PersistenceContext(unitName = PERSISTENCE_NAME)
        private EntityManager em;

        //remove it to work correctly
        @Inject
        private SomeService someService;

        public void observeAfterTransactionFailed(@Observes(during = TransactionPhase.AFTER_FAILURE) @Transaction Long id) {
            log.error("Message from within transaction received after failure: " + id);
            CustomEntity obj= em.find(CustomEntity.class, id);
            someService.onTimeoutMarkAsFinished(id);
        }

And this is not working unless I remove injected service. I am getting following error:

ERROR [org.jboss.weld.Event] (Transaction Reaper Worker 0) WELD-000401: Failure while notifying an observer of event null

Event is fired from method like this:

    @Asynchronous
    @TransactionTimeout(value = 1, unit = TimeUnit.SECONDS)
    public void doStuff() {
        simpleMessageEvent.fire(stepId);
        .
        .
    }

Any idea what is wrong or how could I get more information/logs?

edit: Transaction code:

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
public @interface Transaction {
}

Removing this annotation is not helping

0 Answers
Related