Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-4633

Concurrent Access to @SessionScoped @Stateful beans is not serialised if there is no active transaction

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 7.1.2.Final (EAP)
    • 7.1.0.Final, 7.1.1.Final
    • EJB
    • None
    • Hide

      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 a @Stateless JAX-RS EJB.

      Show
      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 a @Stateless JAX-RS EJB.

    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.

      Attachments

        Activity

          People

            sdouglas1@redhat.com Stuart Douglas
            j4m3s_jira James Fellows (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: