-
Task
-
Resolution: Obsolete
-
Critical
-
None
-
7.1.0.CR3, 7.0.z.GA
-
None
Spec was changed in EJB 3.2. Previously the transaction context for SFSB creation was undefined but in EJB 3.2 the following was adding:
"
By default a stateful session bean’s PostConstruct, PreDestroy, PrePassivate and Post-Activate methods are executed in an unspecified transactional context. A PostConstruct, PreDestroy, PrePassivate and PostActivate method of a stateful session bean with con-tainer-managed transaction demarcation is permitted to have transaction attribute REQUIRES_NEW or NOT_SUPPORTED (RequiresNew or NotSupported if the deployment descriptor is used to spec-ify the transaction attribute).
"
The spec also says that the dependency injection happens in an unspecified transaction context. With this in mind the following decisions were made:
- We will default to REQUIRES_NEW for SFSB creation, it does not make sense to default to REQUIRED or SUPPORTS when these are not valid values for this method
- Dependency injection will take place inside the same transaction as PostContruct
- In order to keep the behaviour consistent dependency injection will still be run inside a new TX even if there is no PostConstuct, otherwise adding an empty PostConstruct method would change the bean creation process in unexpected ways.
So even though this is not 100% following the spec it is designed to follow the principle of least surprise (we don't default to a TX behaviour that is not user specified, and adding an empty method will not change construction semantics).
Need to update quickstarts in any of this ways:
- Avoid using a SFSB as a producer for anything other than an EXTENDED entity manager
- If you are producing an EXTENDED entity manager then don't have anything else in the SFSB producer bean
quickstarts affected:
tasks-jsf
Example, class resources.java
@Stateful public class Resources { @Produces @PersistenceContext private EntityManager em; @Produces public Logger produceLog(InjectionPoint injectionPoint) { return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); } @Produces @RequestScoped public FacesContext produceFacesContext() { return FacesContext.getCurrentInstance(); }
It should only have the produces for the entitymanager.
- relates to
-
JBEAP-5707 SFSB concurrent access timeout when the bean defines CDI producer for bean used in another SFSB
- Closed