According to spec:
1). EntityManager.flush method must be called within an active transaction context.
2). It is the responsibility of the application to associate the entity manager with the transaction by calling EntityManager.joinTransaction.
Therefore calling flush, without associating the application-managed entity manger (that was created outside the scope of the active transaction) with the active JTA transaction, results in throwing TransactionRequiredException. According to spec, A and B are wrong.
However, I tried it in Glassfish and it was not required to explicitly call EntityManager.joinTransaction, I was able to sucessfully perform operations from A and B without calling EntityManager.joinTransaction. Glassfish uses Toplink which provides the JPA functionality for the
EJB 3.0 Reference Implementation. It is probably another Glassfish's inconsistency with spec.