This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SLSB Transaction scoped EntityManager calling SFSB Extended EntityManager

 
eugen grosu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
eugen grosu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic