posted 20 years ago
Here is my thinking.
getUserTransaction() is invoked before a transaction starts. This method only makes sense in the right context. By context, I mean client context. For a stateful session bean, ejbCreate() is only invoked in response to a client's create() method, so this is the right context. The fact that ejbCreate() is called with an unspecified transaction context is irrelevant, you can invoke getUserTransaction() from ejbCreate(). Remember, the ejbCreate() and ejbRemove() methods of a stateful session bean are like business methods.
But for a stateless session bean, ejbCreate() is invoked when the container needs to create instances in the pool, it is nothing to do with the client (which might not even exist at this time). This is why getUserTransaction() can only be called from a business method of a stateless session bean, ie after ejbCreate().
SCJP 1.4, SCWCD 1.3, SCBCD 1.3