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

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Done
    • Affects Version/s: 7.1.0.Final, 7.1.1.Final
    • Fix Version/s: 7.1.2.Final (EAP)
    • Component/s: EJB
    • Labels:
      None
    • Environment:

      Linux Ubuntu 11.10, Sun JDK & JRE 1.6.0_26 Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

    • Steps to Reproduce:
      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  swd847 Stuart Douglas
                  Reporter:
                  j4m3s James Fellows
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: