Katja,

The java.awt.Point class has a method called getLocation. getLocation
will return a "new" instance of Point that contains the same x,y values.
So basically Castor is getting into a never-ending cycle of calling the
getLocation() method. If the getLocation simply returned the same
instance, Castor wouldn't get into a cycle, but it doesn't it returns a
new instance.

Right now you're relying on Castor's default introspection to handle the
mapping for the object into XML...but for this case you can't. Obviously
what you want to do is use a mapping file to prevent Castor from calling
the getLocation method on the point class.

For more information on a mapping file, please see here:

http://castor.exolab.org/xml-mapping.html

The mapping for point should look like this:

<class name="java.awt.Point">
  <field name="x" type="int" direct="true"/>
  <field name="y" type="int" direct="true"/>
</class>


--Keith



Katja wrote:
> 
> Hi,
> I don't understand what you want to say. Maybe it is a language problem.
> I have a java.awt.Point-object and want to save it to a xml-file.
> Again, this is my code:
> Point pnt=new Point(10,20);
>      FileWriter file = new FileWriter("point5.xml");
>       Marshaller.marshal(pnt, file);
>      file.close();
> Can you explane me again, what I have to make sure?
> Katja
> 
> -----Urspr�ngliche Nachricht-----
> Von: Keith Visco [mailto:[EMAIL PROTECTED]
> Gesendet: Freitag, 5. M�rz 2004 19:13
> An: [EMAIL PROTECTED]
> Betreff: Re: [castor-dev] saving Point.class to xml
> 
> You'll need to make sure any self-references are not followed by using a
> mapping file and marking the field as transient:
> 
> <class name="...Point">
>    <field name="point" type="...Point" transient="true"/> </class>
> 
> --Keith
> 
> Katja wrote:
> >
> > Hi again,
> > I forgot to include the xml-file that is marshaled. It might help to
> > solve the problem.  <?xml version="1.0" encoding="UTF-8" ?>
> > - <point x="10.0" y="20.0">
> >         - <location x="10.0" y="20.0">
> >                 - <location x="10.0" y="20.0">
> >                         - <location x="10.0" y="20.0">
> >                                 - <location x="10.0" y="20.0">
> >                                         - <location x="10.0" y="20.0">
> >                                                 - <location x="10.0"
> > y="20.0">
> >                                                         - <location
> > x="10.0" y="20.0">
> > And so on...
> >
> > -----Urspr�ngliche Nachricht-----
> > Von: Katja [mailto:[EMAIL PROTECTED]
> > Gesendet: Donnerstag, 4. M�rz 2004 22:26
> > An: [EMAIL PROTECTED]
> > Betreff: [castor-dev] saving Point.class to xml
> >
> > Hi,
> > I'm trying to to save a object of type java.awt.Point to an xml-file
> > but it doesn't work. This is my code Point pnt=new Point(10,20);
> >     FileWriter file = new FileWriter("point5.xml");
> >      Marshaller.marshal(pnt, file);
> >     file.close();
> >
> > And this is the exception I'm getting: java.lang.StackOverflowError
> > at
> org.exolab.castor.xml.Namespaces.getNamespaceURI(Namespaces.java:200)
> >
> > at
> > org.exolab.castor.xml.Namespaces.getNamespaceURI(Namespaces.java:200).
> > ..
> > Any idea how I can solve that problem?
> >
> > @Jens: I solved all my other problems. Lookes like inner classes don't
> 
> > work.
> >
> > Cheers,
> > Katja
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

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

Reply via email to