About Question enthuware.oce-ejbd.v6.2.412 :

Moderator: admin

deadlock_gr
Posts: 54
Joined: Tue Apr 19, 2011 10:32 am
Contact:

About Question enthuware.oce-ejbd.v6.2.412 :

Post by deadlock_gr »

The class definition should be visible for XBean to show that no TransactionalAttribute is specified. We can't just assume that REQUIRED is implied since we can't see the class definition.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

Hello,

REQUIRED is the default so even if you don't see it, you should assume it as REQUIRED. This is also noted in the explanation for option 3.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

deadlock_gr
Posts: 54
Joined: Tue Apr 19, 2011 10:32 am
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by deadlock_gr »

Even though, we can't see the class definition to see that no other value has been specified. If we could see the class definition, to see that REQUIRED has not been overridden, we are in no position to be sure that it hasn't.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

The question also clearly says, "In absense of any other deployment information related to these beans, ...". So I don't think there is any scope to infer that the transaction attribute has been overridden.
If you like our products and services, please help us by posting your review here.

goetz

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by goetz »

FYI, I was confused the same way as deadlock_gr, and didn't think I could assume XBean has the default REQUIRED transaction attribute.

Alan

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by Alan »

why 'If the client does not have a transaction context, only one transaction context will be used.' is wrong?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

Because as option 3 explains, "Since by default the transaction context of a bean is REQUIRED, there will be one transaction context for XBean (either the client's txn context will be used or a new one will be created for XBean) and since the transaction context is never propagated to an asynchronous invocation, a new one is created for YBean also. "

So there will be two transaction contexts created even if the client doesn't have any transaction context.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Frits Walraven

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by Frits Walraven »

I think there is a @Stateless missing (and the class def.) on the XBean.java, because the question states:

"Consider the following code for two stateless beans" and
"In absense of any other deployment information"

Regards,
Frits Walraven

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

The fact that XBean is stateless is already given in the question. The question also says in absence of any other deployment information (and not "in absence of any deployment information in the bean"). So I think a complete class definition for XBean is not required for the purpose of this question.


HTH,
Paul.
If you like our products and services, please help us by posting your review here.

sanju.ait@gmail.com
Posts: 38
Joined: Fri Aug 16, 2013 11:37 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by sanju.ait@gmail.com »

"If the client does not have a transaction context, only one transaction context will be used."

This seems to be a better option compared to assuming XBean is already in transaction by default.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

sanju.ait@gmail.com wrote:"If the client does not have a transaction context, only one transaction context will be used."

This seems to be a better option compared to assuming XBean is already in transaction by default.
Did you read the explanation for option 3? It explains exactly why 2 transactions will be created whether the client has a transaction or not.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

ssoltanid
Posts: 3
Joined: Wed Nov 12, 2014 3:03 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by ssoltanid »

I read this topic and the answer to the question.
could be asked This kind of question at the exam ?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

Yes, it is possible.
If you like our products and services, please help us by posting your review here.

renatumb
Posts: 47
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by renatumb »

admin wrote:Hello,

REQUIRED is the default so even if you don't see it, you should assume it as REQUIRED. This is also noted in the explanation for option 3.

HTH,
Paul.
Just a complement:
YBean is annotated with REQUIRED, even without this annotation it would run in a transaction context.. As Paul had said:
".. if you don't see it, you should assume it as REQUIRED" ... so, 2 transactions context will be used!

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by himaiMinh »

If the client does not have a transaction context ...
There are two scenarios:
1. The client of XBean does not have a transaction context. But XBean 's regularM () is executed in a transaction by default. YBean's asyncM() executes in its own separate transaction. Therefore, there are only 2 transaction contexts, one is for regularM(), another one is for asyncM()

2. The client refers to XBean, maybe ? If XBean's regularM() has a transaction attribute NotSuppported, then, there is only one transaction context for asyncM().

In my opinion, we need to clarify who the client this option is refering to.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

"If XBean's regularM() has a transaction attribute NotSuppported" cannot happen because the question clearly says< "In absence of any other deployment information or annotations related to these beans". Where there is no such information, then the transaction attributed is assumed to be Required.
If you like our products and services, please help us by posting your review here.

aazizi.tarik
Posts: 31
Joined: Sun Dec 27, 2015 1:47 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by aazizi.tarik »

This "In absence of any other deployment information or annotations related to these beans" doesn't mean that the bean is not a BMT, in that case there will be only one Tx context I guess

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

As per section 13.3.1:
Typically enterprise beans will be specified to have container-managed transaction demarcation. This is the default if no transaction management type is specified.
If you like our products and services, please help us by posting your review here.

aazizi.tarik
Posts: 31
Joined: Sun Dec 27, 2015 1:47 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by aazizi.tarik »

Ok, I thought "absence of any other deployment information or annotations" means that some annotation exist and we don't have the information. sorry its my english wich is bad

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by johnlong »

a new one is created for YBean also.
Where exactly does this new transaction demarcation start : in XBean.regularM() or in YBean.AsyncM?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

The container starts a new one just before it invokes YBean.AsyncM method. It happens in container's code. Not in application code.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by johnlong »

I see, will this transaction cover any application code in this particular example?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

Yes, it will cover asycnM method.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by johnlong »

So transactional context will propagate into asycnM method and it will be new transaction as if RequiresNew transactional attribute specified on asyncM method?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.412 :

Post by admin »

Yes, REQUIRED behaves like REQUIRES_NEW in case of asynchronous calls.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests