Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

EJB3 is it possible to mix BMT and CMT?

 
Ranch Hand
Posts: 51
jQuery Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Is it possible to mix BMT and CMT as in the next example. TestAddCommand method is under BMT and calls methods of AddCommand and RemoveCommand which is under CMT. Is this possible?


 
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Is workable advisable?? (and why not?)

2. For experiment sake,

2.1 For RemoveCommand, instead of return null;
just throw new Exception();

2.2 Run TestAddCommand to see if you have a total rollback and especially for AddCommand in this experiment.
 
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it is possible to mix BMT and CMT. Moreover - the JTA started by the BMT can be reused by CMT, but not the other way around.
So if you have:

Client -> BMT -> CMT(REQUIRED), the CMT will reuse the transaction started by the BMT.
Client -> CMT -> BMT, the BMT will not be able to reuse the transaction started by the BMT.

HTH.

Cheers!

PS. This might be useful for you: http://stackoverflow.com/questions/7196242/why-does-cmt-commit-on-exit-of-ejb-method-when-transaction-attribute-is-required/7218283
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Though not related to actual question here, I am puzzled with the usage (CMT annotation) in the TestAddCommand ejb, even though the class has got annotation (BMT).

Sorry for asking this if this is too trivial, I have started learning ejb recently and got confused seeing such a code.

Thanks
 
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinay Kejriwal wrote:Hi,
Though not related to actual question here, I am puzzled with the usage (CMT annotation) in the TestAddCommand ejb, even though the class has got annotation (BMT).

Sorry for asking this if this is too trivial, I have started learning ejb recently and got confused seeing such a code.

Thanks



It is wrong. =)
 
Vinay Kejriwal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Luan,

But shouldn't this code fail at compile time? I have seen this kind of code getting compiled without any error. So what exactly would be the behavior. Will jvm simply ignore this at runtime?
 
Luan Cestari
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinay Kejriwal wrote:Thanks Luan,

But shouldn't this code fail at compile time? I have seen this kind of code getting compiled without any error. So what exactly would be the behavior. Will jvm simply ignore this at runtime?



Welcome =) About the new questions:

>shouldn't this code fail at compile time? I have seen this kind of code getting compiled without any error. So what exactly would be the behavior. Will jvm simply ignore this at runtime?

The code will not fail in compile time due there isn't this kind of evaluation during this process from the Javac process perspective. Maybe a good IDE may point this as a warning to make you aware that you might not get the desired behavior. The problem about the compile time, the Javac will just see if you have the correct syntax (liek keywords and their order to put in a nutshell) and the dependencies (to make the references inside the .class file). The real "magic" happens in the application server, which the container thread analyze your deployment package and create some proxies and/or aspects to provide the services described in Java EE specification. So, the container may also display some message of warn/error, depeding if it obligation d(if described in Java EE specification or not).

Best regards
 
Vinay Kejriwal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Luan. It helped.
 
Don't MAKE me come back there with this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic