*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes SLSB Transaction scoped EntityManager calling SFSB Extended EntityManager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "SLSB Transaction scoped EntityManager calling SFSB Extended EntityManager" Watch "SLSB Transaction scoped EntityManager calling SFSB Extended EntityManager" New topic
Author

SLSB Transaction scoped EntityManager calling SFSB Extended EntityManager

eugen grosu
Greenhorn

Joined: May 12, 2006
Posts: 4
I tried the following example:
A SLSB, with a injected transaction scoped EntityManager, calls an injected SFSB, with an extended EntityManager.
I tried the example on JBoss 4.2.3.
Both the books I'm reading (Oreilly and Apress), tell that an exception should be thrown in this case (which is logical to me). But it seems from the previous example that an exception is NOT thrown; the transaction is propagated (I'm using @TransactionAttribute.MANDATORY in SFSB), but not the persistence context.

On the server:


I have a client that calls the SLSB from a "main" method:


Can someone explain please what I did wrong?
Thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

This is a nice example. It's true that an exception should be raised as the requirements are :

5.6.3.1 Requirements for Persistence Context Propagation
If a component is called and the JTA transaction is propagated into that component: If the component is a stateful session bean to which an extended persistence context has been bound and there is a different persistence context bound to the JTA transaction, an EJBException is thrown by the container.


This is what I got under Glassfish : "java.rmi.RemoteException: There is an active transactional persistence context for the same EntityManagerFactory as the current stateful session bean's extended persistence context.". So I guess that JBoss is not working as expected.

I tried to extend your example, by making another stateful bean, using an extended persistent scope for the EntityManager. I wanted to make sure that calling the new stateful bean from the first stateful bean would propagate the first bean's extended persistence context. It worked as expected.


[My Blog]
All roads lead to JavaRanch
eugen grosu
Greenhorn

Joined: May 12, 2006
Posts: 4
I tried a lot of examples regarding persistence context propagation and only the one that I described didn't work as expected.

Thanks a lot for your reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SLSB Transaction scoped EntityManager calling SFSB Extended EntityManager
 
Similar Threads
LazyInitializationException
Transactional and Extended Scoped Persistence Context does not work as per spec.
Transaction Context and Persistance context
Extended PersistenceContext on SFSB
Extended persistence context