cancel
Showing results for 
Search instead for 
Did you mean: 

CMR in Entity Beans.

Former Member
0 Kudos

Hi All,

I am trying an example in which i have two Entity beans. They have one to many Bidirectional relationship between them. i have used CMR for this.

but the problem is that when i try to access the Entity bean with occurrence as many. from the entity bean with occurrence one. it gives me an Error.

When it tried to debug the application i found out that when i try to use the collection it gives me Exception as

<b>com.sap.engine.services.ejb.exceptions.BaseIllegalStateException: The collection is obtained by another transaction.</b>

I think the collection is locked by another thread.

does any body has solution for this.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All,

I too gets the same exception.

<b>com.sap.engine.services.ejb.exceptions.BaseIllegalStateException: The collection is obtained by another transaction.</b>

Did anyone resolved this issue?. Please let me know how you have resolved this.

Thanks,

Sekar

Former Member
0 Kudos

I've just the same problem. I'm using a Session Bean with Transaction Type set to Bean, cos I need part of a method to be transactional and the other part not.

I need to set a read lock in a table too. I didn't manage to do this with Container Manager Transaction.

I set the lock checking "Create lock in the database..." in persistent.xml in the defined Bean and "Inmediate load selected objects and set read-locks" in the query method, so it makes a "select ... for update" into the transaction.

After closing the transaction with ut.commit() and trying to read another non-related collection of beans through a 1-n relationship, I get the same Exception:

com.sap.engine.services.ejb.exceptions.BaseIllegalStateException: The collection is obtained by another transaction

How can we figure out which is the other thread locking the collection? I suposse I only have one thread reading the table when I'm testing.

Did anybody get a solution? Thanks in advance.

0 Kudos

Hi,

I have the same problem and has found until now no solutions. I have also this error with 1-to-many relationships. Only 1-to-1 relationships are working from my side.

Former Member
0 Kudos

Hi,

you have to use the right isolation level. Isolation level refers to the degree to which multiple interleaved transactions are prevented from interfering with each other. A higher transaction level is costly in terms of performance. A lower isolation level typically allows greater concurrency at the expense of more complicated logic to handle potential data inconsistencies. A useful guideline is to use the highest isolation level provided by enterprise information systems that gives acceptable performance.

To set the isolation level use the ejb-j2ee-engine.xml -> isolation level in the NWDS.

You can see the following documentation:

http://help.sap.com/saphelp_nw2004s/helpdata/en/13/b7d14f6eb88d4193597131e4608589/frameset.htm

Hope this help.

Best regards,

Vito

Please mark helpful answers

Former Member
0 Kudos

Hi all,

I'm facing exactly the same problem within my application. Vito's solution doesn't work out for me.

The referenced documentation of Vito's replay contains several isolation levels, but it seems, that only "Read Committed" and "Repeatable Read" are allowed on the SAP J2EE. With both levels, I get this error.

Does anybody found a solution in the meantime? Thanks in advance!!!

Cheers,

Matthias

Former Member
0 Kudos

Hi,

I would have a look to the ejb-jar.xml > Assembly > Container Transaction - Settings.

Maybe changing the Attribute of the relevant Business Method from "Container Transaction Required" to "Container Transaction Not supported" will

solve the Problem.

But this only makes sence if the Business Method reads only Data. At writing maybe you will need transactional

security.

Greetings,

Wolfgang