Hi Keith,

Thanks for the quick response. Unfortunately, using either of the approaches
you described results in the same error:

"Unable to find FieldDescriptor for 'localChildElement' in ClassDescriptor
of 'MyCastorObject'"

So, the class descriptor itself gets resolved, but the field descriptors for
its child elements are out of luck.

What could be the reason for not being able to find a FieldDescriptor for a
string field of a class whose descriptor has been found?

Alex


> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]
> Sent: October 12, 2004 12:56 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-user] FieldDescriptor of a string field can't be
> found during unmarshalling
> 
> 
> 
> Alex,
> 
> You certainly don't need to use a mapping file...
> 
> #1. Make sure the class descriptors (*Descripor.java) are compiled
> 
> #2. Try the following instead:
> 
> Unmarshaller unm = new Unmarshaller(MyRoot.class);
> 
> intead of what you're currently doing:
> 
> Unmarshaller unm = new Unmarshaller();
> 
> 
> 
> If you have multiple possible root classes, then you can resolve them
> ahead of time as such:
> 
> ClassDescriptorResolver cdr = new ClassDescriptorResolverImpl();
> cdr.resolve(MyRoot1.class);
> cdr.resolve(MyRoot2.class);
> cdr.resolve(MyRoot3.class);
> 
> //-- now there is no need to pass in the root class
> Unmarshaller unm = new Unmarshaller();
> 
> //-- make sure we set the resolver
> unm.setResolver(cdr);
> 
> 
> --Keith
> 
> Alex Milanovic wrote:
> > Hi All,
> >
> > I have a relatively simple XML schema that I want to use as a basis for
> > marshalling and unmarshalling corresponding Castor-generated objects.
> I'd
> > like to avoid using any mappings, i.e. I'd like Castor to use its
> default
> > and automated marshalling framework. I ran into difficulties with the
> > unmarshalling.
> >
> > I did the following:
> >
> > 1. Generated Castor source files (one for each element + descriptor +
> one
> > for each complex type).
> > 2. Used them in my code to marshal to and unmarshal from XML documents
> as
> > explained on your web site (on the Person example).
> >
> > First, unmarshaller wasn't able to find the Castor-generated class
> despite
> > its being in the classpath. The following message was contained in the
> > exception: "The class for the root element ... could not be found". From
> > this I inferred that the unmarshaller does not look in the classpath for
> > classes with the same name as the given element, so I decided to specify
> the
> > class name using a mapping file (I wanted to avoid this, but it seemed
> > impossible).
> >
> > I created a mapping file with the following class information:
> >
> > <class name="<class name>" auto-complete="true" >
> >      <map-to xml="<element name>" ns-uri="<ns uri>"/>
> > </class>
> >
> > The class name, element name and namespace URI were correct, as the same
> > information worked fine in the complete mapping configuration that I was
> > eventually forced to try out.  In the code, I wrote as follows:
> >
> > Unmarshaller unm = new Unmarshaller();
> > unm.setMapping(allMappings);
> > castorMessage = unm.unmarshal(sourceDoc);
> >
> > This resulted in the following error message:
> > "Unable to find FieldDescriptor for 'localChildElement' in
> ClassDescriptor
> > of 'MyCastorObject'"
> >
> > The same happens with or without the auto-complete attribute. The child
> > element that Castor complains about is just a string field. The
> > FieldDescriptor is present in MyCastorObject's ClassDescriptor, but the
> > unmarshaller doesn't find it. What can the reason be for its inability
> to
> > find the FieldDescriptor?
> >
> > The only way I managed to get this to work is by specifying a complete
> > mapping for each class, but this is exactly what I wanted to avoid.
> Please
> > help.
> >
> > I looked at the information on the web site, but often this information
> > doesn't emphasize whether a piece of information applies to only
> marshalling
> > or unmarshalling, or both at the same time. I tried out different
> > combinations that should work according to the web site, but nothing
> worked
> > except the complete-mapping approach.
> >
> > Alex
> >
> >
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-user
> >
> 
> 
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user



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

Reply via email to