Description: Issue during Java To XML conversion :
Activity output data conversion error. Exception [java.lang.RuntimeException] occurred while trying to create the activity output data. java.lang.RuntimeException: Illegal circular reference: (object type = sun.misc.Launcher$AppClassLoader: value = sun.misc.Launcher$AppClassLoader@134a33d) -- use an ID and IDREF instead. - com.tibco.plugin.java.JavaPluginException - JavaPluginException - BusinessProcesses/SubProcesses/UserJavaService_SubProc_design1.process/Java To XML.
Symptoms: During Design time, the output element is recursive to display endlessly. For example,
'Java to XML' output 'Student' that contains sub-element 'name', 'subject' and 'grade' only. However, when you expand the output tree of 'Student', besides of 'name', 'subject', etc., it also contains itself 'Student' inside of it. Going to the next level sub student, it still has student in side of it. In the runtime, it will throw the exception "Java.lang.RuntimeException: Illegal circular reference: ' Cause: There is a method in this class which returns object "this": For example:
package test1;
public class Student implements java.io.Serializable {
public int i=0;
public Student getFoo() {
return this;
}
}
This is OK inside Java, but when you try to convert such an object to XML, the conversion tries to make the object a child of itself and throws the "circular reference" exception. This is caused by the fact that Java and XML are different technologies and not meant to be convertible in general. There is no industry standard on how to convert one to the other. XML is a data representation while Java code defines the functional behavior with data hiding feature. TIBCO's approach on JavaToXML is to convert not only the public fields in the Java object but the private fields which are accessible by the mutator functions. For example, if the Java code has:
public int getFoo()
JavaToXML will create a Foo element and assign the value by calling getFoo() during the conversion. This is a nice feature in most cases because using mutator functions to hide the private data members is a common practice in OO programming. However, this causes issues when getXXX is not meant to be a mutator function (in some cases, maybe a object of itself).