-
1. Re: Problem with CMR and transaction, need help
aloubyansky Jun 22, 2004 4:06 AM (in response to bassie)When there is a transaction, there is no difference between CMT and UserTransaction. In your case there is no transaction.
-
2. Re: Problem with CMR and transaction, need help
bassie Jun 23, 2004 5:32 AM (in response to bassie)thank you for the reply,
In my case I defined the transaction using xdoclet, I put my snipped ejb-jar below. I would like to work with CMT. I think there is transaction here. What is the reason actually the exception thrown when I invoke size() method in Collection ? This part make fail.
I would appreciate your further answer.
<container-transaction >
<ejb-name>QueueManagement</ejb-name>
<method-intf>Local</method-intf>
<method-name>deleteQueue</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>QueueManagement</ejb-name>
<method-intf>Remote</method-intf>
<method-name>deleteQueue</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>QueueManagement</ejb-name>
<method-intf>Local</method-intf>
<method-name>deleteQueues</method-name>
<method-params>
<method-param>java.lang.String[]</method-param>
</method-params>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>QueueManagement</ejb-name>
<method-intf>Remote</method-intf>
<method-name>deleteQueues</method-name>
<method-params>
<method-param>java.lang.String[]</method-param>
</method-params>
<trans-attribute>Required</trans-attribute>
</container-transaction> -
3. Re: Problem with CMR and transaction, need help
cvandyck Jun 23, 2004 12:19 PM (in response to bassie)Try putting some transactional debugging in your code, especially in the deleteQueue(String queueName) method.
Use this class to help determine if there is a transaction in your deleteQueue method when you are deleting multiple queues.import javax.naming.InitialContext; import javax.transaction.Status; import javax.transaction.TransactionManager; /** * @author Collin VanDyck * */ public class TransactionInfo { public static final String getTransactionInformation() { String result = ""; try { TransactionManager tm = (TransactionManager) new InitialContext().lookup("java:/TransactionManager"); int status = tm.getStatus(); switch (status) { case Status.STATUS_ACTIVE: result = "ACTIVE"; break; case Status.STATUS_COMMITTED: result = "COMMITTED"; break; case Status.STATUS_COMMITTING: result = "COMMITTING"; break; case Status.STATUS_MARKED_ROLLBACK: result = "MARKED_ROLLBACK"; break; case Status.STATUS_NO_TRANSACTION: result = "NO_TRANSACTION"; break; case Status.STATUS_PREPARED: result = "PREPARED"; break; case Status.STATUS_PREPARING: result = "PREPARING"; break; case Status.STATUS_ROLLEDBACK: result = "ROLLEDBACK"; break; case Status.STATUS_ROLLING_BACK: result = "ROLLING_BACK"; break; case Status.STATUS_UNKNOWN: result = "UNKNOWN"; break; default: result = "UNDEFINED"; } } catch (Exception e) { result = "ERROR: could not get tx status: " + e.getMessage(); } return result; } }
Use that class and let us know the transactional status when you are deleting a specific queue, as called by your deleteQueues() method.
My guess is that, as lou mentioned, there is not a transactional context. -
4. Re: Problem with CMR and transaction, need help
aloubyansky Jun 24, 2004 2:52 AM (in response to bassie)In the previous post you wrote that tx attribute is Never. So there is no tx. CMR collection was created in a tx and accessed then w/o tx.
-
5. Re: Problem with CMR and transaction, need help
bassie Jun 24, 2004 6:19 AM (in response to bassie)Thanks Collin,
It's nice debug tool. When I specify Tx=Required in deleteQueue and Tx=Never in deleteQueues, then I call deleteQueues method, I got this:
10:39:50,062 INFO [STDOUT] delQueues Tx status: NO_TRANSACTION
10:39:50,062 INFO [STDOUT] delQueue Tx status: NO_TRANSACTION
10:39:50,078 ERROR [LogInterceptor] RuntimeException:
java.lang.IllegalStateException: A CMR collection may only be used within the tr
ansction in which it was created
at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.getIdList(RelationS
et.java:66)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.size(RelationSet.ja
va:74)
If I specify Tx=Required in deleteQueue and don't specify any Tx type id deleteQueues, I got this:
11:07:51,093 INFO [STDOUT] delQueues Tx status: ACTIVE
11:07:51,093 INFO [STDOUT] delQueue Tx status: ACTIVE
Then I have a problem, because for example I want to delete 5 queues and one failed then everything rollback, instead, I still want to delete the other four.
My objective is that client will be able to delete single queue or multiple. Deleting multiple queues will not be rollback if one failed.
For Alexey, I'm sorry posting the wrong ejb-jar, below is the right one.
<container-transaction >
<ejb-name>QueueManagement</ejb-name>
<method-intf>Local</method-intf>
<method-name>rmDeleteQueues</method-name>
<method-params>
<method-param>java.lang.String[]</method-param>
</method-params>
<trans-attribute>Never</trans-attribute>
</container-transaction>
<container-transaction >
<ejb-name>QueueManagement</ejb-name>
<method-intf>Remote</method-intf>
<method-name>rmDeleteQueues</method-name>
<method-params>
<method-param>java.lang.String[]</method-param>
</method-params>
<trans-attribute>Never</trans-attribute>
</container-transaction>
I highly appreciate your help. -
6. Re: Problem with CMR and transaction, need help
aloubyansky Jun 25, 2004 4:56 AM (in response to bassie)The use RequiresNew for deletion of each queue. But access CMP in transaction.