I'm wondering what happens if i call a business method in a CMT bean that has the transaction behaviour "supports" and I call for example getRollbackOnly:
the spec says(126.96.36.199 Supports):
� If the client calls with a transaction context, the Container performs the same steps as described in the Required case. � If the client calls without a transaction context, the Container performs the same steps as described in the NotSupported case.
would mean: - with transaction context => works - without transaction context => IllegalStateException (according to HeadFirstEJB)
how can I handle "supports" as bean provider then ?
Actually, if you look a little further in the spec, section 188.8.131.52 states that: "The Container must handle the EJBContext.getRollbackOnly() method invoked from a business method executing with the Required, RequiresNew, or Mandatory transaction attribute. The Container must throw the java.lang.IllegalStateException if the EJBContext. getRollbackOnly() method is invoked from a business method executing with the Supports, NotSupported, or Never transaction attribute."
...which corroborates what HeadFirstEJB says.
In the section you quote (184.108.40.206), there is also a very important note at the end, which is: "The Supports transaction attribute must be used with caution. This is because of the different transactional semantics provided by the two possible modes of execution. Only the enterprise beans that will execute correctly in both modes should use the Supports transaction attribute."
In case of a business method with a Supports transaction attribute, if the client calls without a meaningful transaction context, the container will throw an IllegalStateException. This is a system level exception, and thus, the container will apply the usual rules for taking care of this (as summarized in Table 15, p. 375, last two rows): - Log the exception - Discard the bean instance - Throw RemoteException to remote clients and EJBException to local clients
Also, it is important to read section 17.6.5 to understand what happens in the case the bean runs within an unspecified transaction context.