You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Andrew Duckworth <an...@yahoo.com.au> on 2005/08/30 03:44:50 UTC
Betwixt problem on cyclic bean graphs
Hi,
I'm using betwixt 0.7 and in a test case I'm trying to write XML for
two beans, a parent & a child that refer to each other. This works
correctly with beanWriter.setWriteEmptyElements(true), but fails with a
StackOverflowError when beanWriter.setWriteEmptyElements(true). I have also
tested with the current nightly build and it does the same thing, is
this expected behaviour ?
Kind Regards,
Andrew Duckworth
andrew_duckworth@yahoo.com.au
java.lang.StackOverflowError
at
org.apache.commons.betwixt.expression.MethodExpression.getArguments(MethodExpression.java:126)
at
org.apache.commons.betwixt.expression.MethodExpression.evaluate(MethodExpression.java:59)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.isEmptyElement(AbstractBeanWriter.java:1114)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.isEmptyElement(AbstractBeanWriter.java:1103)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.isEmptyElement(AbstractBeanWriter.java:1120)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.isEmptyElement(AbstractBeanWriter.java:1103)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.isEmptyElement(AbstractBeanWriter.java:1120)
.... more omitted for brevity :)
public class ParentBean
{
/** nested child */
private ChildBean child;
/**
* Returns the child of this instance.
*
* @return the value of child
*/
public ChildBean getChild()
{
return child;
}
/**
* Modifies the child of this instance.
*
* @param aBean the new value of child
*/
public void setChild(ChildBean aBean)
{
child = aBean;
}
}
public class ChildBean
{
/** nested bean */
private ParentBean parent;
/**
* Returns the parent of this instance.
*
* @return the value of bean
*/
public ParentBean getParent()
{
return parent;
}
/**
* Modifies the parent of this instance.
*
* @param aBean the new value of bean
*/
public void setParent(ParentBean aBean)
{
parent = aBean;
}
}
test case:
public void testCircularBeanGraphToXml()
{
ParentBean bean = new ParentBean();
ChildBean nestedBean = new ChildBean();
bean.setChild(nestedBean);
nestedBean.setParent(bean);
......
}
Send instant messages to your online friends http://au.messenger.yahoo.com
Re: Betwixt problem on cyclic bean graphs
Posted by Thomas Dudziak <to...@gmail.com>.
On 8/30/05, Andrew Duckworth <an...@yahoo.com.au> wrote:
> I'm using betwixt 0.7 and in a test case I'm trying to write XML for
> two beans, a parent & a child that refer to each other. This works
> correctly with beanWriter.setWriteEmptyElements(true), but fails with a
> StackOverflowError when beanWriter.setWriteEmptyElements(true). I have also
> tested with the current nightly build and it does the same thing, is
> this expected behaviour ?
I think, Betwixt can work with cyclic structurs, by using the XML
ID-IDREF mechanism for them. I'm not sure what the default setting is,
but you can try to set
beanWriter.getBindingConfiguration().setMapIDs(true);
which leads to the generation of an id attribute at each written element.
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org