Can I use an Extended Persistence Context in a Clustered environment? Is it possible to safely put a reference to a JPA Extended Persistence Context in HttpSession or as a reference in a Stateful EJB Session Bean and have it failover successfully? Answer: The JPA spec is not (yet) clear how the container and persistence provider should work together to even passivate a stateful session bean with an extended persistence context in a stand-alone server instance. This same problem prevents successful serialization and storage of a reference to an Extended Persistence Context in HttpSession. So in GlassFish today this scenario will not work and must be avoided. Even in a single-instance environment, storage of an Extended Persistence Context in an SFSB must be avoided too because of the danger that the SFSB will be passivated and the Extended Persistence Context lost when the SFSB is activated. In a single-instance environment, it is safe to store a reference of an Extended Persistence Context in HttpSession. And in this environment, it is safe to store in an SFSB only if you can safely configure SFSB passivation policy so that SFSB's are never passivated. This is possible but has trade-offs in memory utilization that must be carefully examined before choosing this option. If HttpSession is available to you, that is the best choice for the single-instance environment.
|