Damon,

I've had a StackOverflow when a class contained a getParent() method, so
that when I marshalled the parent it included the child...which called
getParent() to include the parent...which included the child...and so on
until the stack overflowed. Default Castor marshalling uses introspection
and so calls the available property getters.

I got round this by specifying the mapping file and leaving out getParent().

Jeremy.

-----Original Message-----
From: Damon Hill [mailto:[EMAIL PROTECTED]
Sent: 21 July 2004 20:57
To: [EMAIL PROTECTED]
Subject: [castor-user] Newbie: Java.lang.StackOverflowError


Good day.

I did a cursory search of the archives and didn't find anything directly
related to my query.
That is not to say it isn't out there and I missed it, however, I am new
to Castor and in need of a little assistance.

I have the following binding file:

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Ojbect Mapping DTD Version
1.0//EN"
"http://castor.exolab.org/mapping.dtd";>
<mapping>
   <class name="com.xxxx.rdcc.application.RepairOrder">
      <map-to xml="repairOrder" />
      <field name="_jobs" type="OutboundJob" collection="vector">
         <bind-xml name="job" />
      </field>
      <field name="_equipment" type="Equipment" required="true">
         <bind-xml name="equipment" />
      </field>
      <field name="_repairOrderStartDate" type="string" required="true">
         <bind-xml name="repairOrderStartDate" />
      </field>
      <field name="_deviceID" type="string" required="true">
         <bind-xml name="serialNumber" />
      </field>
      <field name="_lastUpdateTime" type="string" required="true">
         <bind-xml name="lastUpdateTime" />
      </field>
   </class>
   <class name="com.xxxxx.rdcc.application.Shed">
      <field name="_equipment" type="Equipment" collection="vector">
         <bind-xml name="equipment" />
      </field>
   </class>
   <!-- Only unmarshalling from the equipment xml -->
   <class name="com.xxxxx.rdcc.application.Equipment">
      <field name="_equipmentID" type="string" required="true">
         <bind-xml name="equipmentId" />
      </field>
      <field name="_equipmentSpec" type="string" required="true">
         <bind-xml name="equipmentSpec" />
      </field>
      <field name="_equipmentUnitNumber" type="string" required="true">
         <bind-xml name="equipmentUnitNumber" />
      </field>
      <field name="_equipmentUnitPrefix" type="string" required="true">
         <bind-xml name="equipmentUnitPrefix" />
      </field>
      <field name="_equipmentType" type="string" required="true">
         <bind-xml name="equipmentType" />
      </field>
      <field name="_equipmentStatus" type="string" required="true">
         <bind-xml name="equipmentStatus" />
      </field>
   </class>
   <class name="com.xxxx.rdcc.application.FilingCabinet">
      <field name="_currentJobs" type="OutboundJob" collection="vector">
         <bind-xml name="job" />
      </field>
   </class>
   <class name="com.xxxx.rdcc.application.OutboundJob">
      <map-to xml="job" />
      <field name="_rdccTime" type="RDCCJobTime" collection="vector">
         <bind-xml name="time" />
      </field>
      <field name="_parts" type="Part" collection="vector">
         <bind-xml name="part" />
      </field>
      <field name="_picture" type="Picture" collection="vector">
         <bind-xml name="picture" />
      </field>
      <field name="_jobStatus" type="string" required="true">
         <bind-xml name="jobStatus" />
      </field>
      <field name="_jobID" type="string" required="true">
         <bind-xml name="jobID" />
      </field>
      <field name="_jobType" type="string" required="true">
         <bind-xml name="jobType" />
      </field>
      <field name="_technicianID" type="string" required="true">
         <bind-xml name="technicianID" />
      </field>
      <field name="_equipmentNumber" type="string" required="true">
         <bind-xml name="equipmentNumber" />
      </field>
      <field name="_equipmentPrefix" type="string" required="true">
         <bind-xml name="equipmentPrefix" />
      </field>
      <field name="_inventoryLocation" type="string">
         <bind-xml name="inventoryLocation" />
      </field>
      <field name="_inspectionRepairLocation" type="string">
         <bind-xml name="inspectionRepairLocation" />
      </field>
      <field name="_accountCode" type="string">
         <bind-xml name="accountCode" />
      </field>
      <field name="_jobCode" type="string">
         <bind-xml name="jobCode" />
      </field>
      <field name="_cause" type="string">
         <bind-xml name="cause" />
      </field>
      <field name="_jobPosition" type="string">
         <bind-xml name="jobPosition" />
      </field>
      <field name="_damagePosition" type="string">
         <bind-xml name="damagePosition" />
      </field>
      <field name="_damagedArea" type="string">
         <bind-xml name="damagedArea" />
      </field>
      <field name="_correctionCode" type="string">
         <bind-xml name="correctionCode" />
      </field>
      <field name="_condition" type="string">
         <bind-xml name="condition" />
      </field>
      <field name="_workPerformed" type="string">
         <bind-xml name="workPerformed" />
      </field>
   </class>
   <class name="com.xxx.rdcc.application.RDCCJobTime">
      <field name="_technicianNumber" type="string" required="true">
         <bind-xml name="techncianID" />
      </field>
      <field name="_startTime" type="string" required="true">
         <bind-xml name="startTime" />
      </field>
      <field name="_startDate" type="string" required="true">
         <bind-xml name="startDate" />
      </field>
      <field name="_endTime" type="string" required="true">
         <bind-xml name="endTime" />
      </field>
      <field name="_endDate" type="string" required="true">
         <bind-xml name="endDate" />
      </field>
   </class>
   <class name="com.xxxx.rdcc.application.Part">
      <field name="_partNumber" type="string" required="true">
         <bind-xml name="partNumber" />
      </field>
      <field name="_partQuantity" type="string" required="true">
         <bind-xml name="partQuantity" />
      </field>
      <field name="_tirePartRemoved" type="string">
         <bind-xml name="tirePartRemoved" />
      </field>
      <field name="_tireTreadDepthRemoved" type="string">
         <bind-xml name="tireTreadDepthRemoved" />
      </field>
      <field name="_tirePartInstalled" type="string">
         <bind-xml name="tirePartInstalled" />
      </field>
      <field name="_tireTreadDepthInstalled" type="string">
         <bind-xml name="tireTreadDepthInstalled" />
      </field>
   </class>
   <class name="com.xxxxx.rdcc.application.Picture">
      <field name="_filename" type="string">
         <bind-xml name="before" />
      </field>
      <field name="_filename" type="string">
         <bind-xml name="after" />
      </field>
   </class>
   <!-- only unmarshalling the spec not writing to it -->
   <class name="com.xxxxx.rdcc.application.Spec">
      <field name="_specID" type="string" required="true">
         <bind-xml name="specId" />
      </field>
      <field name="_jobNumber" type="string" required="true">
         <bind-xml name="jobNumber" />
      </field>
      <field name="_jobPosition" type="string" required="true">
         <bind-xml name="jobPosition" />
      </field>
      <field name="_partNumber" type="string" required="true">
         <bind-xml name="partNumber" />
      </field>
      <field name="_minQuantity" type="string" required="true">
         <bind-xml name="minQuantity" />
      </field>
      <field name="_maxQuantity" type="string" required="true">
         <bind-xml name="maxQuantity" />
      </field>
      <field name="_status" type="string" required="true">
         <bind-xml name="status" />
      </field>
   </class>
</mapping>

I am attempting to write out a java object with this code
Mapping _mapping = new Mapping();
_mapping.loadMapping(RDCCProperties.ROOT_DIR + "castorBinding.xml")
public void writeTempData(OutboundJob job)
{
        String technicianNumber = job.getTechnicianID();
        System.out.println("tech id is " + technicianNumber);
        try
          {
                Marshaller marshaller = new Marshaller(new
java.io.OutputStreamWriter(new


java.io.FileOutputStream(RDCCProperties.TEMP_DATA_STORE +
technicianNumber + ".xml")));
                  marshaller.setMapping(_mapping);
                  marshaller.marshal(job);
           }
          catch (Exception ex)
          {
                ex.printStackTrace();
          }
}
I will not post the code, but I have verified that all fields match
correctly.
I have this method to test marshalling

public void writeTempData(OutboundJob job)
{
        String technicianNumber = job.getTechnicianID();
        System.out.println("tech id is " + technicianNumber);
        try
          {
                Marshaller marshaller = new Marshaller(new
java.io.OutputStreamWriter(new

java.io.FileOutputStream(RDCCProperties.TEMP_DATA_STORE +
technicianNumber + ".xml")));
                marshaller.setMapping(_mapping);
                marshaller.marshal(job);
          }
         catch (Exception ex)
         {
                ex.printStackTrace();
         }
}

As soon as this method is executed I simply get
        java.lang.StackOverflowError

Any thoughts?

Thanks in advance
Damon



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to