The main problem with the code is that the @TransactionAttribute
annotation has no effect at all. In your pollTimer()
method you're doing a simple local method invocation, therefore the EJB container doesn't know that you want a new transaction for each of your poller methods.
If you inject an EJB with @EJB
, the container injects only a proxy, therefore it can intercept the EJB method invocations and do the necessary work, like tx management. However, there is no interception in your case, because you're doing a local method invocation.
The following things happen in your case:
- At time-out the
pollTimer()
method starts running in a new tx managed by the container
- The first and the second poller method get invoked in the exact same tx.