I get a CyclicReferenceException while using Betwixt to write a bean. I get
this exception on our development server - websphere 5.1, JDK 1.4.2.5, AIX 5.2,
betwixt 0.7, hibernate 3.1. However the same code works on my local workstation
- webshere 5.1, J2RE 1.4.2 , XP version 5.1, betwixt 0.7, hibernate 3.1. We are
using .betwixt files for all bean properties that needs to be written.
In further digging through the trace logs, I find a whole bunch of
ClassCastException just before the CyclicReferenceException is thrown. Any idea
what may be causing the ClassCastExceptions?
The error seems to be happening only when there is one or more instance of a
particular bean type within the object graph.
For example, Person bean is used to generate Person.xml. Person bean has
Address bean as a property. We get the error mainly when there is an address
record for a Person as a result of which it instantiates an Address bean.
Thankyou
Sailesh
-----------------------------ClassCastException-------------------------------------------------------------------------
[10/24/06 12:47:52:027 EDT] 3a828432 AbstractBeanW E
org.apache.commons.betwixt.io.AbstractBeanWriter [MethodExpression] Cannot
evaluate expression
[10/24/06 12:47:52:027 EDT] d138432 ORBRas d com.ibm.rmi.iiop.CDROutputStream
setStreamFormatVersion:387 Alarm : 1 custom stream format=1
[10/24/06 12:47:52:046 EDT] 3a828432 AbstractBeanW E
org.apache.commons.betwixt.io.AbstractBeanWriter TRAS0014I: The following
exception was logged java.lang.IllegalArgumentException:
java.lang.ClassCastException@1eb2442e
at sun.reflect.GeneratedMethodAccessor464.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled
Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at
org.apache.commons.betwixt.expression.MethodExpression.evaluate(MethodExpression.java(Compiled
Code))
at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeElementContent(AbstractBeanWriter.java(Compiled
Code))
...
at
org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWriter.java:144)
at org.apache.commons.betwixt.io.BeanWriter.write(BeanWriter.java:190)
.
java.lang.IllegalArgumentException: java.lang.ClassCastException@1eb2442e
at sun.reflect.GeneratedMethodAccessor464.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled
Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at
org.apache.commons.betwixt.expression.MethodExpression.evaluate(MethodExpression.java(Compiled
Code))
...
at
org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWriter.java:144)
at org.apache.commons.betwixt.io.BeanWriter.write(BeanWriter.java:190)
------------------------------Cyclic
referenceException-----------------------------------
[10/13/06 8:50:17:980 EDT] 5e3e469a AbstractBeanW E
org.apache.commons.betwixt.io.AbstractBeanWriter Cyclic reference at bean:
XXXXXXXX
[10/13/06 8:50:17:990 EDT] 5e3e469a SystemErr R
org.apache.commons.betwixt.io.CyclicReferenceException: Bean graph contains a
cyclic reference
[10/13/06 8:50:17:991 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.pushBean(AbstractBeanWriter.java:1014)
[10/13/06 8:50:17:991 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:348)
[10/13/06 8:50:17:991 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:267)
[10/13/06 8:50:17:991 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeElementContent(AbstractBeanWriter.java:936)
[10/13/06 8:50:17:992 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWriter.java:144)
......
[10/13/06 8:50:17:992 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.BeanWriter.write(BeanWriter.java:190)
----------------------------------------------------------Code-----------------------------------------------------
...
outputWriter.write("<?xml version='1.0' ?>");
BeanWriter beanWriter = new BeanWriter(outputWriter);
IntrospectionConfiguration introConfig =
beanWriter.getXMLIntrospector().getConfiguration();
introConfig.setAttributesForPrimitives(false);
introConfig.setMappingDerivationStrategy(MappingDerivationStrategy.USE_INTROSPECTION_TIME_TYPE);
introConfig.setWrapCollectionsInElement(true);
PropertySuppressionStrategy pss = new PropertySuppressionStrategy() {
public boolean suppressProperty(Class clazz, Class type, String
name) {
if (clazz == com.xxx.yyy.zzz)
return true;
else
return false;
}
};
introConfig.setPropertySuppressionStrategy(pss);
beanWriter.getBindingConfiguration().setMapIDs(false);
beanWriter.enablePrettyPrint();
beanWriter.write(this);
...
...
This e-mail transmission contains information that is confidential and may be
privileged. It is intended only for the addressee(s) named above. If you
receive this e-mail in error, please do not read, copy or disseminate it in any
manner. If you are not the intended recipient, any disclosure, copying,
distribution or use of the contents of this information is prohibited. Please
reply to the message immediately by informing the sender that the message was
misdirected. After replying, please erase it from your computer system. Your
assistance in correcting this error is appreciated.
|