Forums Register Login

EJB3 is it possible to mix BMT and CMT?

1
+Pie Number of slices to send: Send
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?


+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 

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. =)
+Pie Number of slices to send: Send
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?
1
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
Thanks Luan. It helped.
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 6775 times.
Similar Threads
NullPointerException returned usig a StoredProcedureCall
Strange behaviour of MDB and EJB
EclipseLink1.1 inserts no data..
How to retrieve the string from textbox using Midlet to invoke the JSP
How to invoke the MIDlet ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:02:34.