Hi Keith,
if I try the following:
Mapping mapping = new Mapping(getClass().getClassLoader());
mapping.loadMapping("castor.xml");
MappingResolver resolver = mapping.getResolver(Mapping.JDO);
ClassDescriptor desc = resolver.getDescriptor(Class.forName(className));
FieldDescriptor[] fields = desc.getFields();
for(int i = 0; i < fields.length; ++i)
{
logger.info(fields[i].getFieldType().getName());
}
I get the following Exception:
org.xml.sax.SAXException: unable to find FieldDescriptor for 'driver' in
ClassDescriptor of mapping
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown
Source)
at
org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1340)
at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java:1214)
at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
r.java:1806)
at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1182)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at org.exolab.castor.mapping.Mapping.loadMappingInternal(Unknown
Source)
at org.exolab.castor.mapping.Mapping.loadMappingInternal(Unknown
Source)
at org.exolab.castor.mapping.Mapping.loadMapping(Unknown Source)
If I use castor with the normal application, all workes fine.
Can you help me on this?
Thanks,
Silvio
> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]]
> Sent: 19 November 2002 21:13
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] Access to mapping information
>
>
>
> Mapping information for objects can be obtained from the Mapping object
> itself. First you need to obtain the MappingResolver from the Mapping as
> such:
>
> import org.exolab.castor.mapping.*;
>
> MappingResolver resolver = myMapping.getResolver(Mapping.JDO);
>
> Then using the resolver you can obtain the ClassDescriptor for any class
> listed in your mapping file:
>
> ClassDescriptor cd = resolver.getDescriptor(Foo.class);
>
> --Keith
>
> Silvio Katzan wrote:
> >
> > Hi all,
> >
> > if I have a jdo or database object, is there any possibility to
> access the
> > mapping information.
> > The goal is to get information about a field, if it is using a
> collection
> > and which type is stored in this collection.
> >
> > Thanks,
> >
> > Silvio
> >
> >
> ------------------------------------------------------------------------
> > Name: winmail.dat
> > winmail.dat Type: application/ms-tnef
> > Encoding: base64
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
<<attachment: winmail.dat>>
