Hi Joachim,
My name is Simon :)
I've attached the code snippet you requested. It fails on the
following line (line 16 in the file) and then throws a LoadException.
return unmarshaller.unmarshal(inputStream);
Thanks again.
-Simon-
On Wed, Nov 26, 2008 at 10:45 AM, Joachim Grüneis <[EMAIL PROTECTED]> wrote:
> Hello Godard,
>
> can you please provide the code snipped which terminates with this
> exception... it must be something with XMLContext, Unmarshaller, ...
>
> Regards
> Joachim
>
> 2008/11/26 Simon Godard <[EMAIL PROTECTED]>:
>> Hi,
>>
>> I'm trying to use a ClassDescriptorResolver as describe in Castor's
>> Best practices, but I've run into problems.
>>
>> First, I had to update my version to 1.3rc1 to fix a
>> NullPointerException. After my update, I'm now getting this
>> exception:
>> IllegalStateException: No Introspector defined in properties! thrown
>> by the ByIntrospection class. I've debugged the code and found out
>> that the Introspector is not set when using the Best practices
>> approach. My XMLClassDescriptorResolver _introspector, _classLoader
>> variables are all null.
>>
>> Am I missing something?
>> I've attached a stackframe and variables view from Eclipse.
>>
>> Here is the stacktrace:
>> Caused by: java.lang.IllegalStateException: No Introspector defined in
>> properties!
>> at
>> org.exolab.castor.xml.util.resolvers.ByIntrospection.internalResolve(ByIntrospection.java:85)
>> at
>> org.exolab.castor.xml.util.resolvers.AbstractResolverClassCommand.resolve(AbstractResolverClassCommand.java:55)
>> at
>> org.exolab.castor.xml.util.resolvers.CastorXMLStrategy.getDescriptor(CastorXMLStrategy.java:137)
>> at
>> org.exolab.castor.xml.util.resolvers.CastorXMLStrategy.resolveClass(CastorXMLStrategy.java:82)
>> at
>> org.exolab.castor.xml.util.XMLClassDescriptorResolverImpl.resolve(XMLClassDescriptorResolverImpl.java:289)
>> at
>> org.exolab.castor.xml.MarshalFramework.searchInheritance(MarshalFramework.java:506)
>> at
>> org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1867)
>> at
>> org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1420)
>> at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
>> Source)
>> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>> at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:748)
>> at
>> com.coradiant.configuration.xml.XmlObjectReader.read(XmlObjectReader.java:258)
>> ... 25 more
>>
>> Thanks
>> Simon Godard
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
public XmlObjectReader(Mapping mapping) {
if(mapping == null) {
throw new IllegalArgumentException("No XML mapping
object provided.");
}
this.xmlClassDescriptorResolver =
createXmlClassDescriptorResolver(mapping);
}
public Object read(Reader reader) throws LoadException,
ArgumentFormatException {
try {
InputSource inputStream = new InputSource(reader);
Unmarshaller unmarshaller = new Unmarshaller();
unmarshaller.setResolver(xmlClassDescriptorResolver);
unmarshaller.setWhitespacePreserve(true);
return unmarshaller.unmarshal(inputStream);
} catch(ArgumentFormatException ex) {
throw ex;
} catch(Throwable ex) {
throw new LoadException(ex);
}
}
private XMLClassDescriptorResolver
createXmlClassDescriptorResolver(Mapping mapping) {
XMLClassDescriptorResolver resolver = (XMLClassDescriptorResolver)
ClassDescriptorResolverFactory.createClassDescriptorResolver(BindingType.XML);
MappingUnmarshaller mappingUnmarshaller = new
MappingUnmarshaller();
MappingLoader loader = null;
try {
loader = mappingUnmarshaller.getMappingLoader(mapping,
BindingType.XML);
} catch(MappingException e) {
throw new IllegalArgumentException(e.toString());
}
resolver.setMappingLoader(loader);
return resolver;
}---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email