Details
-
Bug
-
Resolution: Done
-
Critical
-
7.1.0.Final, 7.1.1.Final
-
None
Description
Concurrent calls to @Stateful @SessionScoped beans in the absence of a transaction (for example where the method being invoked is annotated @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) are not serialized and (I believe) they should be, byt the container. Concurrent access to the same method annotated @TransactionAttribute(TransactionAttributeType.REQUIRED) IS serialised correctly.
Moreover, when concurrent access to the bean occurs in the absence of a transaction, no errors are logged - the instance is simply removed from the pool leading to NullPointerExceptions on subsequent calls (from any thread).
I have looked at the unit tests for org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor (which is where I believe the issue lies - see explanation in the forum), but I really don't understand it. I'm not familiar with Mockito, but as far as I can tell the functionality is only tested during Bean and Container Managed transactions, not in their absence.
The problem can be recreated in an integration-test scenario by making multiple concurrent calls to a @Stateful @sessionScoped bean. In my case my app makes the calls from @Stateless JAX-RS services.
In the world of AJAX and tabbed browsing I believe this issue to be significant. I suspect transaction-less calls will become more common as people get used to the @PersistenceContext(type=PersistenceContextType.EXTENDED) EntityManagers and the flexibility they allow (it's heavily featured in Adam Bien's Rethinking J2EE Patterns book). There have been some discussions on StackOverflow of people trying to figure out the issue, but only very few.