• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

SLSB Transaction scoped EntityManager calling SFSB Extended EntityManager

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic