Discussion:
[jboss-user] [EJB3] - EJB 2.1 BMP with CMT and RequiresNew in JBoss AS 7.1.0 Final
Daniel Zhelyazkov
2012-04-05 08:03:20 UTC
Permalink
Daniel Zhelyazkov [https://community.jboss.org/people/dzhelyazkov] created the discussion

"EJB 2.1 BMP with CMT and RequiresNew in JBoss AS 7.1.0 Final"

To view the discussion, visit: https://community.jboss.org/message/728441#728441

--------------------------------------------------------------
I have the folowing case where transactions lock up, and it was working OK in JBoss 3, 4 and 6.

We have the Session Facade pattern where the SLSB calls the Entity Bean, both SLSBs and EntityBeans use RequiresNew as transaction attribute. (Changing the Entity Beans attribute to Requires solves the problem, too much places to fix, and some tricky situations where more changes are required)

So what happens is:

*SLSB.newRecord(...) starts with RequiresNew*
*{*
    //with RequiresNew (the insert statement is executed, then by spec on TX end ejbLoad is called and data is read from Database - so far so good.
*record = EntityHome.create(...);*

     //method part of the local interface of the Entity - here a new transaction is started, and at the end of the method the transacion is commited and ejbStore is called, however this does not work because of db lock which I can not understand.
*record.getProperties(); *
*}*

The datasource isolation level is READ_COMMITED.
In previous versions of JBoss call to record.getProperties() did not start new transaction and no call to ejbStore


I hope someone could help,
Daniel
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/728441#728441]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Daniel Zhelyazkov
2012-04-05 08:17:11 UTC
Permalink
Daniel Zhelyazkov [https://community.jboss.org/people/dzhelyazkov] created the discussion

"Re: EJB 2.1 BMP with CMT and RequiresNew in JBoss AS 7.1.0 Final"

To view the discussion, visit: https://community.jboss.org/message/728447#728447

--------------------------------------------------------------
Turns out I was wrong, the Entity Bean was recently changed to Requres. So what happens is this
SLSB starts TX1
Entity creates record within TX1
record.getProperties() starts new TX2 and calls update and commit at end of TX2, and here lock happens

the question remains why record.getProperties() spawns new TX

daniel
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/728447#728447]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Daniel Zhelyazkov
2012-04-05 15:40:16 UTC
Permalink
Daniel Zhelyazkov [https://community.jboss.org/people/dzhelyazkov] created the discussion

"Re: EJB 2.1 BMP with CMT and RequiresNew in JBoss AS 7.1.0 Final"

To view the discussion, visit: https://community.jboss.org/message/728546#728546

--------------------------------------------------------------
Fixed my problem, after debug session of JBoss code it turned out that the code that parses TX attributes produces wrong info.
we had the folowing in ejb-jar.xml

<method>
     <ejb-name>SomeEjb</ejb-name>
     <method-name>*</method-name>
</method>
...
<trans-attribute>RequiresNew</trans-attribute>

Specified like that JBoss set default TX attribute Required to all LOCAL_HOME methods (ejbCreate/Find/Select/Home)
and RequiresNew to all Bean methods such as toString(), hashCode()...

by adding <method-intf>LocalHome</method-intf>

<method>
     <ejb-name>SomeEjb</ejb-name>
     <method-intf>LocalHome</method-intf>
     <method-name>*</method-name>
</method>

all went to normal, my ejbCreate() started new transaction, and getProperties() method did not use TX interceptor.

So it looks like different or wrong loginc in JBoss, the code itself states it has some problems, and it looks targeted at EJB 3.x, it is not a separate code for 2.x

daniel
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/728546#728546]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
jaikiran pai
2012-07-08 07:29:30 UTC
Permalink
jaikiran pai [https://community.jboss.org/people/jaikiran] created the discussion

"Re: EJB 2.1 BMP with CMT and RequiresNew in JBoss AS 7.1.0 Final"

To view the discussion, visit: https://community.jboss.org/message/746793#746793

--------------------------------------------------------------
Post by Daniel Zhelyazkov
Fixed my problem, after debug session of JBoss code it turned out that the code that parses TX attributes produces wrong info.
we had the folowing in ejb-jar.xml
<method>
     <ejb-name>SomeEjb</ejb-name>
     <method-name>*</method-name>
</method>
...
<trans-attribute>RequiresNew</trans-attribute>
Specified like that JBoss set default TX attribute Required to all LOCAL_HOME methods (ejbCreate/Find/Select/Home)
and RequiresNew to all Bean methods such as toString(), hashCode()...
by adding <method-intf>LocalHome</method-intf>
<method>
     <ejb-name>SomeEjb</ejb-name>
     <method-intf>LocalHome</method-intf>
     <method-name>*</method-name>
</method>
all went to normal, my ejbCreate() started new transaction, and getProperties() method did not use TX interceptor.
So it looks like different or wrong loginc in JBoss, the code itself states it has some problems, and it looks targeted at EJB 3.x, it is not a separate code for 2.x
daniel
Daniel, have you been able to reproduce this against the latest nightly build https://community.jboss.org/thread/167590 https://community.jboss.org/thread/167590 or maybe 7.1.1.Final?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/746793#746793]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Wolf-Dieter Fink
2013-06-08 12:48:30 UTC
Permalink
Wolf-Dieter Fink [https://community.jboss.org/people/wdfink] created the discussion

"Re: EJB 2.1 BMP with CMT and RequiresNew in JBoss AS 7.1.0 Final"

To view the discussion, visit: https://community.jboss.org/message/822121#822121

--------------------------------------------------------------
This is reproducable with EAP6.1.

I've created a bug for this https://bugzilla.redhat.com/show_bug.cgi?id=971284 https://bugzilla.redhat.com/show_bug.cgi?id=971284
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/822121#822121]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Loading...