Ah ha!

It needs those "read-only" tags in jboss.xml in order to fail.

Previously, I had explicitly specified that "getChildren" was read-only. It needs to be "get*".

My test is failing now.

Steve Coy


On Thursday, April 3, 2003, at 01:30 AM, Andrew May wrote:


I've tried to do a bit of investigation of my own. I'm still trying to get my head around the code, but this is what I think is going on.

The exception:

java.lang.IllegalStateException: The iterator of a CMR collection may only be used within the transction in which it was created
at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet$1.verifyIteratorIsVal id(RelationSet.java:309)


gets throws when setHandle[0] is null. This reference to a set of ids is nullified by JDMCCMRFieldBridge$FieldState.invalidate().

When two threads (A & B) are using the Entity at the same time (which is allowed because the getPropertyMap method is read-only) it's possible for thread A to nullify setHandle[0] (at the end of it's transaction) whilst thread B is in the middle of iterating around the relationship. After that any call to the CMR iterator in thread B causes the exception - which is why it's sometimes from hasNext() and sometimes from next().

Here's a couple of Thead stacks I captured using the test case. The first thread is in the middle of iterating, and the second is finishing it's transaction:

System Thread [RMI TCP Connection(172)-192.168.5.20] (Suspended)
java.lang.StringBuffer.<init>(int) line: 114 [local variables unavailable]
java.lang.StringBuffer.<init>() line: 103
com.ingenta.acs.test.ejb.ParentBean$Proxy(com.ingenta.acs.test.ejb.Pare ntBean).getPropertyMap() line: 86
sun.reflect.GeneratedMethodAccessor87.invoke(java.lang.Object, java.lang.Object[]) line: not available [local variables unavailable]
sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25 [local variables unavailable]
java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(org.jboss.inv ocation.Invocation) line: 1044
org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(org.jboss .invocation.Invocation) line: 95
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(org.jboss .invocation.Invocation) line: 295
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke (org.jboss.invocation.Invocation) line: 186
org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(org.jboss.invo cation.Invocation) line: 82
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(org.jboss.invoca tion.Invocation) line: 174
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(org.jboss.invocation .Invocation) line: 89
org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(org.jboss.invoca tion.Invocation) line: 53
org.jboss.ejb.plugins.TxInterceptorCMT(org.jboss.ejb.plugins.AbstractTx Interceptor).invokeNext(org.jboss.invocation.Invocation, boolean) line: 84
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(org.jboss.in vocation.Invocation) line: 243
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(org.jboss.invocation.Invo cation) line: 104
org.jboss.ejb.plugins.SecurityInterceptor.invoke(org.jboss.invocation.I nvocation) line: 117
org.jboss.ejb.plugins.LogInterceptor.invoke(org.jboss.invocation.Invoca tion) line: 198
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(org.jboss.in vocation.Invocation) line: 122
org.jboss.ejb.EntityContainer.internalInvoke(org.jboss.invocation.Invoc ation) line: 483
org.jboss.ejb.EntityContainer(org.jboss.ejb.Container).invoke(org.jboss .invocation.Invocation) line: 678
sun.reflect.GeneratedMethodAccessor85.invoke(java.lang.Object, java.lang.Object[]) line: not available
sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25
java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(java.lang.Strin g, java.lang.Object[], java.lang.String[]) line: 284
org.jboss.mx.server.MBeanServerImpl.invoke(javax.management.ObjectName, java.lang.String, java.lang.Object[], java.lang.String[]) line: 549
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(org.jboss.invocatio n.Invocation) line: 358
sun.reflect.GeneratedMethodAccessor84.invoke(java.lang.Object, java.lang.Object[]) line: not available
sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) line: 25
java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) line: 324
sun.rmi.server.UnicastServerRef2(sun.rmi.server.UnicastServerRef).dispa tch(java.rmi.Remote, java.rmi.server.RemoteCall) line: 261
sun.rmi.transport.Transport$1.run() line: 148
java.security.AccessController.doPrivileged(java.security.PrivilegedExc eptionAction, java.security.AccessControlContext) line: not available [native method]
sun.rmi.transport.tcp.TCPTransport(sun.rmi.transport.Transport).service Call(java.rmi.server.RemoteCall) line: 144
sun.rmi.transport.tcp.TCPTransport.handleMessages(sun.rmi.transport.Con nection, boolean) line: 460
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run() line: 701
java.lang.Thread.run() line: 536


System Thread [RMI TCP Connection(175)-192.168.5.20] (Suspended (breakpoint at line 1611 in org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$FieldState))
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$FieldState.inv alidate() line: 1611
org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$TxSynchronizat ion.beforeCompletion() line: 1730
org.jboss.tm.TransactionImpl.doBeforeCompletion() line: 1297
org.jboss.tm.TransactionImpl.commit() line: 338
org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(org.jboss.invocat ion.Invocation, javax.transaction.Transaction, javax.transaction.Transaction) line: 367
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(org.jboss.in vocation.Invocation) line: 253
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(org.jboss.invocation.Invo cation) line: 104
[snip - as above]


I'm afraid some of the line numbers will be a bit different to CVS because I added some extra logging to JDBCCMRFIeldBridge and RelationSet.

Also I modified the ParentBean.getPropertyMap method so that I could see the individual steps (I used the System.out method of debugging to start :).

From PropertyBean:

76:   public Map getPropertyMap()
77:   {
78:      String thread = Thread.currentThread().getName();
79:      Map result = new HashMap();
80:      Set children = getChildren();
81:      System.out.println(thread+": Got Children");
82:      Iterator i = children.iterator();
83:      System.out.println(thread+": Got Iterator");
84:      while (i.hasNext())
85:      {
86:         System.out.println(thread+": hasNext");
87:         ChildLocal c = (ChildLocal) i.next();
88:         System.out.println(thread+": next");
89:         result.put(c.getName(), c.getValue());
90:      }
91:
92:      return result;
93:   }

The exception will happen when the first thread resumes and calls the next line (87) which gets from the iterator.

I think that's probably the cause of the error. I don't understand the code enough to suggest a solution.

Andrew



-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to