Usually when you see ClassCastException in an application server
environment it is because of the interaction between the different
ClassLoaders. A class is usually defined by its fully quantified name
plus the ClassLoader that defines it.
Consider the case where the same jar is being loaded by two different
ClassLoaders, even though the byte code is the same, they are considered
to be different classes.
In WebSphere you can set the order in which the application server looks
for classes. The hierarchy is usually search in a "Parent First" mode.
This can be changed in the Admin Console. I would check this setting in
both environments and see if it is different.
Regards,
Mark Wehby
-----Original Message-----
From: Rao, Sailesh [mailto:Sailesh.Rao@xxxxxx]
Sent: Tuesday, October 24, 2006 3:56 PM
To: users@xxxxxxxxxx
Subject: [cinjug-users] Error when writing XML using Betwixt
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(DelegatingMethodAccessor
Impl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at
org.apache.commons.betwixt.expression.MethodExpression.evaluate(MethodEx
pression.java(Compiled Code))
at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeElementContent(Abs
tractBeanWriter.java(Compiled Code))
...
at
org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWrite
r.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(DelegatingMethodAccessor
Impl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at
org.apache.commons.betwixt.expression.MethodExpression.evaluate(MethodEx
pression.java(Compiled Code))
...
at
org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWrite
r.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(AbstractBeanWr
iter.java:1014)
[10/13/06 8:50:17:991 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanW
riter.java:348)
[10/13/06 8:50:17:991 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanW
riter.java:267)
[10/13/06 8:50:17:991 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeElementContent(Abs
tractBeanWriter.java:936)
[10/13/06 8:50:17:992 EDT] 5e3e469a SystemErr R at
org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWrite
r.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_I
NTROSPECTION_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.
---------
You may unsubscribe from this mailing list
by sending a blank email addressed to:
users-unsubscribe@xxxxxxxxxx
--
Find additional help by sending a blank email
addressed to:
users-help@xxxxxxxxxx
|