“Unspecified Transaction Context”

The term “an unspecified transaction context” is the EJB spec’s way of saying, “You have no clue. I (the container) can do whatever I want and you’ll just have to deal!”

image with no caption

You must know, for the exam, the methods (and circumstances) that might be running in an “unspecified transaction context.”

  • Any CMT method marked NotSupported, Never, or Supports. NotSupported and Never are supposed to mean “no transaction”, but in reality, the container can do whatever it wants. And with Supports, you never know anyway (which is why we think it’s a really dumb attribute that nobody should ever use).

  • CMT session bean methods ejbCreate() (any of them), ejbRemove(), ejbPassivate(), ejbActivate(). The create and remove methods of a session bean are not considered part of a client’s transaction (unlike the way it works with entity beans). And remember, activate and passivate will never be called if the session bean is in a transaction.

  • CMT message-driven bean methods ejbCreate() and ejbRemove(). Remember, for a message-driven bean, ejbCreate() and ejbRemove() are called by the container when it wants to add or remove beans from the pool. There’s no calling client transaction, because a message-driven bean doesn’t have a real client!

Note

The point is... YOU DON’T KNOW!

The key point here is that you must NOT rely on any exact behavior from the container because you just don’t ...

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.