Ralf,

Thanks again for your suggestion-
I thought I would send a little more of the stack
trace of the error I got when implementing your
suggestions:

java.lang.StackOverflowError
        at java.lang.Object.hashCode(Native Method)
        at java.util.Hashtable.get(Hashtable.java:333)
        at
org.exolab.castor.xml.util.ClassDescriptorResolverImpl.resolve(ClassDescriptorResolverImpl.java:223)
        at
org.exolab.castor.xml.Validator.validate(Validator.java:111)
        at
org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:250)
        at
org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:886)
        at
org.exolab.castor.xml.Validator.validate(Validator.java:122)
        at
org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:250)
        at
org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:886)
        at
org.exolab.castor.xml.Validator.validate(Validator.java:122)

......and so on- it seems to be in an infinite loop
with the field validator.

Do you have any ideas about this?

Thanks again for your help,

Jim


--- Ralf Joachim <[EMAIL PROTECTED]> wrote:
> 
> Hey Jim,
> 
> I am not an expert for castor XML, but have you
> tried something like
> 
> public class Foo {
> ......
> public void setBar(Bar bar) {
> if (this.bar != bar) {
> this.bar = bar;
> bar.setFoo(this);
> }}
> ......
> }
> 
> public class Bar {
> .......
> public void setFoo(Foo foo) {
> if (this.foo != foo) {
> this.foo = foo;
> foo.setBar(this);
> }}
> .......
> }
> 
> MfG
> Ralf
> 
> 
> ----- Original Message ----- 
> From: "Jim Otte" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, February 17, 2004 6:56 AM
> Subject: [castor-dev] Obtaining refernceto Parent
> class-Castor limitation??
> 
> 
> > 
> > Castor Gurus:
> > 
> > I have the following xml to be unmarshalled:
> > 
> > <foo>
> > <id>42</id>
> > <bar>
> > <greeting>hello world</greeting> 
> > </bar> 
> > </foo>
> > 
> > into the following classes:
> > 
> > 
> > public class Foo {
> > public Bar bar;
> > public String id;
> > 
> > public Bar getBar() {
> > return bar;
> > }
> > 
> > 
> > public void setBar(Bar bar) {
> > this.bar = bar;
> > }
> > 
> > 
> > public String getId() {
> > return id;
> > }
> > 
> > public void setId(String id) {
> > this.id = id;
> > }
> > 
> > }
> > 
> > 
> > and 
> > 
> > 
> > public class Bar {
> > 
> > public String greeting;
> > public Foo foo;
> > 
> > 
> > public String getGreeting() {
> > return greeting;
> > }
> > 
> > 
> > public void setGreeting(String greeting) {
> > this.greeting = greeting;
> > }
> > 
> > 
> > public Foo getFoo() {
> > return foo;
> > }
> > 
> > 
> > public void setFoo(Foo foo) {
> > this.foo = foo;
> > }
> > 
> > }
> > 
> > where in Bar I would like a reference to the
> parent
> > class Foo.
> > I set up the mapping as such:
> > 
> > <?xml version="1.0"?>
> > <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object
> > Mapping DTD Version 1.0//EN"
> >                         
> > "http://castor.exolab.org/mapping.dtd";>
> > 
> > <mapping>
> > 
> > <class name="tudo.foobar.castor.domain.Foo">
> >                 <map-to xml="foo"/>
> > 
> >                 <field name="id"
> > type="java.lang.String">
> >                         <bind-xml name="id"
> > node="element"/>
> >                 </field>
> >                 
> >                 <field name="bar"
> > type="tudo.foobar.castor.domain.Bar">
> >                         <bind-xml name="bar"
> > node="element"/>
> >                 </field>
> >      </class>
> >      
> >      <class name="tudo.foobar.castor.domain.Bar">
> >                 <map-to xml="bar"/>
> > 
> >                 <field name="greeting"
> > type="java.lang.String">
> >                         <bind-xml name="greeting"
> > node="element"/>
> >                 </field>
> >                 
> >                 <field name="foo"
> > type="tudo.foobar.castor.domain.Foo" >
> >                         <bind-xml name="foo" />
> >                 </field>
> >      </class>
> >      
> > </mapping>
> > 
> > 
> > and test it as such:
> > 
> > private void execute(){
> > Mapping      mapping = new Mapping();
> > 
> > try {
> > // 1. Load the mapping information from the file
> > mapping.loadMapping( "fooMap.xml" );
> > 
> > // 2. Unmarshal the data
> > Unmarshaller unmar = new Unmarshaller(mapping);
> > Foo foo = (Foo)unmar.unmarshal(new InputSource(new
> > FileReader("FooTest.xml")));
> > 
> > // 3. Do some processing on the data
> > System.out.println(foo.getBar().getGreeting());
> > System.out.println(foo.getBar().getFoo().getId());
> > } catch (Exception e) {
> > System.out.println(e);
> > return;
> > }
> > }
> > 
> > 
> > and the result is:
> > 
> > hello world
> > java.lang.NullPointerException
> > 
> > I have tried setting the location attribute to
> ".."
> > but it does not seem to go "backwards". I have
> also
> > tried handlers but can only get the current class-
> not
> > the parent class.
> > 
> > Does anyone know how to get a reference to the
> parent
> > class of which another class is a member- as just
> > described????
> > I tried many sources but have come up with
> nothing- is
> > this a Castor limitation?????
> > 
> > Thaanks,
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

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

Reply via email to