Bugs item #634910, was opened at 2002-11-07 13:03
Message generated for change (Settings changed) made by loubyansky
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=634910&group_id=22866

Category: JBossCMP
Group: v3.0 Rabbit Hole
Status: Open
Resolution: None
Priority: 5
Submitted By: Alexei Yudichev (sflexus)
>Assigned to: Alexey Loubyansky (loubyansky)
Summary: arbitrary Exception: iterator of a CMR..

Initial Comment:
Jboss 3.0.4, CMP2.0 bean, simple business method is called by 
remote client. Method declaration is:

public String 
getSizeAsString(Locale locale) {
try {
int size = 0;
316: 
for (Iterator i = getSlides().iterator(); i.hasNext(); ) 
{
size+=((Slide)i.next()).getSize();
}
size+=getXml(false, 
false, -1, locale).toString().getBytes("UTF-8").length;
return 
new 
DecimalFormat("0.00").format((double)size/1024D);
}catch 
(UnsupportedEncodingException ex) {
throw new 
EJBException(ex);
}
}

>From time to time (not every 
time, approx one time for 20 invocations) I get the exception below. 
All transaction attributes for all beans in application declared 
as:

<container-
transaction>
<method>
<description />
<ejb-
name>SMIL</ejb-name>
<method-name>*</method-
name>
</method>
<trans-attribute>Required</trans-
attribute>
</container-transaction>

Looks pretty 
much like a bug with instable reproduce. I cannot provide a 
testcase as well because it happens rarely. What can be the 
cause? Can I help somehow else?

2002-11-05 
17:54:20,987 ERROR [org.jboss.ejb.plugins.LogInterceptor] 
RuntimeException:
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.verifyIteratorIsValid(RelationSet.java:309)
at 
org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet$1.hasNext(RelationSet.java:269)
at 
com.tw.mms.ejb.SMILBean.getSizeAsString(SMILBean.java:316)
at 
sun.reflect.GeneratedMethodAccessor75.invoke(Unknown 
Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at 
java.lang.reflect.Method.invoke(Method.java:324)
at 
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1194)
at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:95)
at 
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:297)
at 
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)

at 
org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:90)
at 
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)
at 
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
at 
org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
at 
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
at 
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
at 
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
at 
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
at 
org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
at 
org.jboss.ejb.Container.invoke(Container.java:712)
at 
org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
at 
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at 
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
at 
sun.reflect.GeneratedMethodAccessor59.invoke(Unknown 
Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at 
java.lang.reflect.Method.invoke(Method.java:324)
at 
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at 
sun.rmi.transport.Transport$1.run(Transport.java:148)
at 
java.security.AccessController.doPrivileged(Native 
Method)
at 
sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at 
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at 
java.lang.Thread.run(Thread.java:536)

----------------------------------------------------------------------

Comment By: Jernej Srebrni&#269; (jernej4321)
Date: 2004-03-30 11:52

Message:
Logged In: YES 
user_id=990160

I'm able to reproduce on 3.2.3 and 3.2.4RC1 
we have bean A and bean B
1:N relation 
CMP beans

metod:
col=A.getBs();
i=col.iterator();
foj(int j=0; j<col.size;j++){
   i.next();
   if(j==2) break;
}

steps (transaction mod is not relevant):
  col this metod with the same data in paralel (2 or more
clients)

explanation:  
if you do not iterate throw the entaire collection zou get
the exception. that's way the proposed workaround works (new
ArrayList(col) does the iteration).

hint to the problem:
beause its a cmb ration it is allways in a transaction,
transaction   setings dont meter. the retrived beans are
locked... the itrated one are "marked" when iterating so at
the end of the transaction the are unlocked. the beans we
did not interact with are not "marked" so their remain locked..


pleas rise priority

----------------------------------------------------------------------

Comment By: Alexei Yudichev (sflexus)
Date: 2002-11-11 09:34

Message:
Logged In: YES 
user_id=345880

Today I saw exception of this kind at the point where it never happened 
before. Something is really wrong with RelationSet transaction check. It 
cannot be in a different transaction when I directly invoke new 
ArrayList(getSlides()) where getSlides() is a cmr getter.
In the 
stacktace getXml() and getOrderedSlideList() are private bean 
methods.

BTW I overcame the problem I described in the original 
comment (at least it never happened since I did that) simply by invoking 
new ArrayList(getSlides()).iterator() instead of getSlides().iterator() 
by this bypassing direct iterator() call on CMR collection.

Here's 
the new exception:

2002-11-09 18:11:49,993 ERROR 
[org.jboss.ejb.plugins.LogInterceptor] 
RuntimeException:
java.lang.IllegalStateException: A CMR 
collection may only be used within the transction in which it was 
created
        at 
org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.getIdList(RelationSet.java:58)
        at 
org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet.size(RelationSet.java:65)
        at 
java.util.ArrayList.<init>(ArrayList.java:128)
        at 
com.tw.mms.ejb.SMILBean.getOrderedSlideList(SMILBean.java:89)
        at 
com.tw.mms.ejb.SMILBean.getXml(SMILBean.java:72)
        at 
com.tw.mms.ejb.SMILBean.getXmlWithData(SMILBean.java:314)
        at 
sun.reflect.GeneratedMethodAccessor110.invoke(Unknown 
Source)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at 
java.lang.reflect.Method.invoke(Method.java:324)
        at 
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1194)
        at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:95)
        at 
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:297)
        at 
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
        at 
org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:90)
        at 
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)
        at 
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
        at 
org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
        at 
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
        at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
        at 
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
        at 
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
        at 
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
        at 
org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
        at 
org.jboss.ejb.Container.invoke(Container.java:712)
        at 
org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
        at 
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
        at 
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
        at 
sun.reflect.GeneratedMethodAccessor59.invoke(Unknown 
Source)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at 
java.lang.reflect.Method.invoke(Method.java:324)
        at 
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
        at 
sun.rmi.transport.Transport$1.run(Transport.java:148)
        at 
java.security.AccessController.doPrivileged(Native Method)
        at 
sun.rmi.transport.Transport.serviceCall(Transport.java:144)
        at 
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
        at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
        at 
java.lang.Thread.run(Thread.java:536)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=634910&group_id=22866


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to