commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amir Rezazadeh <>
Subject RE: Betwixt - CyclicReferenceException
Date Thu, 18 Sep 2003 16:26:09 GMT
I have been working on a project where we use betwixt to serialize an
object to XML. When we had a cyclical reference problem. We set the
beanWriter.setWriteIDs(true), this gives every object in the graph an ID
and prevents the looping. However, the id is now an attribute that is
part of the resulting XML. 

I am still learning this stuff so I hope I did not confuse you.


On Thu, 2003-09-18 at 11:15, Hope, Matthew wrote:

> A cyclical reference is when a loop exists in your object graph (or indeed
> any type of graph)
> If you have 
> A- > B
> B -> C
> C -> A
> Then a loop exists and if some algorithm is meant to 'walk' through the
> graph and do something at each node (object) then in the situation above it
> would walk forever going round in a loop.
> Graph traversal (walk) algorithms often include mechanisms to avoid loops,
> either by terminating in a failure state (throw an exception) or by not
> traversing an edge to a node already visited.
> This implementation is maintaining a set of nodes visited and when a node is
> revisited it throws an exception.
> One area where this can be a pain is if you have a structure
> A -> B via variable x
> A -> B via variable y
> In this case a naïve algorithm will call this a revisit - I don't know if
> betwixt does though
> Your two examples would contain one which has no such loop and another which
> does. Perhaps in one you are reusing an object in two different variables?
> Matt
> -----Original Message-----
> From: Michael Watson [] 
> Sent: 18 September 2003 16:58
> To: Jakarta Commons Users List
> Subject: Betwixt - CyclicReferenceException
> Hi,
> I'm having issues with cyclic references and was wondering if anyone can
> shed some light for me.
> I'm calling BeanWriter.write (on a reasonably complex bean) and occasionally
> getting a cyclicreferenceexception thrown.
> I can reproduce the problem easily but the thing that's confusing me is that
> I can call this method with another instance of the same type of bean (with
> near identical data) and it doesn't throw an exception.
> Can anyone explain exactly what a cyclic reference is, how I might be able
> to identify what part of the bean is causing it and how I can try and avoid
> it?
> Thanks in advance.
> Mike
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
> **************************************************************************
> The information transmitted herewith is sensitive information intended only
> for use by the individual or entity to which it is addressed. If the reader
> of this message is not the intended recipient, you are hereby notified that
> any review, retransmission, dissemination, distribution, copying or other
> use of, or taking of any action in reliance upon this information is
> strictly prohibited. If you have received this communication in error,
> please contact the sender and delete the material from your computer.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Amir Rezazadeh <>
PDX, Inc.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message