I managed to get things to work, finally. Although I must say that I am not pleased with the way I had to do things. At this point I don't see any difference between CMT and BMT based upon my configuration.
My EJB's were currently annotated with:
@TransactionAttribute(TransactionAttributeType.REQUIRED)
This should cause the container to initiate the Transaction. To use only the TransactionManager within my application I needed to configure the Spring JtaTransactionManager to not perform a JNDI look-up of the TM or the UT. Instead I supplied the TM to the JtaTransationManager and specifically told it to not look for the UT. This causes the JtaTransactionManager to wrap the supplied TransactionManager into a Spring UserTransactionAdapter object that delegates all calls down to the PlatformTransactionManager (GlassFish). I also told the JtaTransactionManager where to locate the TransactionSynchronizationRegistry so it could utilize this as well.
With the above configuration I was able to perform some database operations but ran into issues with Hibernate and lazy loaded collections. It seems that the Hibernate Session was getting closed by Spring. This only occurs when Spring things the transaction has committed. The problem was that it hadn't committed. The CMT Transaction was still active but that did not seem to be conveyed to Spring from the TransactionSynchronizationRegistry. The only way I was able to get things to work correctly was by adding the following Spring annotation to my service.
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
Now after the container begins the CMT transaction and the method is invoked, Spring will begin a transaction and synchronize it with the PlatformTransactionManager. Of course this results in Springs request participating in an existing transaction. But what is the point? If I have to go through all this then why would I want to use a CMT? Spring can manage it for me easier and if I choose to let Spring manage the transactions completely then I can allow Spring to use the UserTransaciton as well. Seems to me I should just abandon the use of CMT with my EJB's and allow Spring to manage it completely.
In addition, if I did for some reason choose to participate in a CMT, then using the above configuration would not benefit me if ever I needed to suspend an existing transaction, for those methods are only available on the UserTransaction object.
[Message sent by forum member 'cmathrusse' (cmathrusse)]
http://forums.java.net/jive/thread.jspa?messageID=290200