hi,

i have downloaded the most recent snapshot and afterwards debugged into the 
unmarshaller instance.
i have put an eye on the
_descriptorCache of the _xmlClassDescriptorResolver in the _internalContext,
which for some reason does not contain an entry for class 'TopLevelA' in its 
_xmlNameMap
but contains an entry 'com.xyz.model.A' in its _missingTypes list.

because the element '{http://www.xyz.com/}A' appears twice, i'd say castor 
consequently finds the 'NestedA' 
instead of the required 'TopLevelA' for the document element.

if i have properly configured castor, that seems to be a bug. but i can hardly 
imagine why you can't reproduce that. 
will invest another unit to check the environment.

regards, 
reinhard


ps, i have appended castor's debugging output. maybe that helps:

+++ debugging output +++

[Configuration] Configuration loaded from classpath: 
/org/castor/core/castor.core.properties
[Configuration] Configuration loaded from classpath: 
/org/castor/xml/castor.xml.properties
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] New instance!
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.LoadPackageMappings to value: true
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.useIntrospection to value: true
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.MappingLoader to value: null
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.Introspector to value: [EMAIL 
PROTECTED]
[AbstractResolverPackageCommand] Now in resolve method: 
org.exolab.castor.xml.util.resolvers.ByCDR resolving: com.xyz.model
[AbstractResolverPackageCommand] No domain class loader set, taking it from 
class.getClassLoader().
[ByCDR] Found descriptor: class com.xyz.model.descriptors.AnotherTypeDescriptor
[ByCDR] Found descriptor: class com.xyz.model.descriptors.NestedADescriptor
[ByCDR] Found descriptor: class com.xyz.model.descriptors.SomeTypeDescriptor
[ByCDR] Found descriptor: class com.xyz.model.descriptors.TopLevelADescriptor
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding descriptor class 
for: com.xyz.model.NestedA descriptor: [EMAIL PROTECTED]; descriptor for class: 
[null]; xml name: null
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding descriptor class 
for: com.xyz.model.TopLevelA descriptor: [EMAIL PROTECTED]; descriptor for 
class: [null]; xml name: null
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding descriptor class 
for: com.xyz.model.AnotherType descriptor: [EMAIL PROTECTED]; descriptor for 
class: [null]; xml name: null
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding descriptor class 
for: com.xyz.model.SomeType descriptor: [EMAIL PROTECTED]; descriptor for 
class: [null]; xml name: null
[AbstractResolverPackageCommand] Now in resolve method: 
org.exolab.castor.xml.util.resolvers.ByPackageMapping resolving: com.xyz.model
[AbstractResolverPackageCommand] No domain class loader set, taking it from 
class.getClassLoader().
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Called addAllDescriptors 
with null or empty descriptor map
[XMLContext] Creating new Unmarshaller instance.
[Configuration] Configuration loaded from classpath: 
/org/castor/core/castor.core.properties
[Configuration] Configuration loaded from classpath: 
/org/castor/xml/castor.xml.properties
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] New instance!
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Get descriptor for: 
com.xyz.model.A found: null
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.LoadPackageMappings to value: true
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.useIntrospection to value: true
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.MappingLoader to value: null
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.Introspector to value: [EMAIL 
PROTECTED]
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.ClassLoader to value: [EMAIL 
PROTECTED]
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.LoadPackageMappings to value: true
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.useIntrospection to value: true
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.MappingLoader to value: null
[CastorXMLStrategy] Setting property: 
org.exolab.castor.xml.util.ResolverStrategy.Introspector to value: [EMAIL 
PROTECTED]
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Get descriptor for: 
com.xyz.model.A found: null
[AbstractResolverClassCommand] Now in method: 
org.exolab.castor.xml.util.resolvers.ByMappingLoader resolving: com.xyz.model.A
[ByMappingLoader] No mapping loader specified
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Called addAllDescriptors 
with null or empty descriptor map
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Get descriptor for: 
com.xyz.model.A found: null
[AbstractResolverPackageCommand] Now in resolve method: 
org.exolab.castor.xml.util.resolvers.ByCDR resolving: com.xyz.model
[ByCDR] Found descriptor: class com.xyz.model.descriptors.AnotherTypeDescriptor
[ByCDR] Found descriptor: class com.xyz.model.descriptors.NestedADescriptor
[ByCDR] Found descriptor: class com.xyz.model.descriptors.SomeTypeDescriptor
[ByCDR] Found descriptor: class com.xyz.model.descriptors.TopLevelADescriptor
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding descriptor class 
for: com.xyz.model.NestedA descriptor: [EMAIL PROTECTED]; descriptor for class: 
[null]; xml name: null
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding descriptor class 
for: com.xyz.model.TopLevelA descriptor: [EMAIL PROTECTED]; descriptor for 
class: [null]; xml name: null
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding descriptor class 
for: com.xyz.model.AnotherType descriptor: [EMAIL PROTECTED]; descriptor for 
class: [null]; xml name: null
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding descriptor class 
for: com.xyz.model.SomeType descriptor: [EMAIL PROTECTED]; descriptor for 
class: [null]; xml name: null
[AbstractResolverPackageCommand] Now in resolve method: 
org.exolab.castor.xml.util.resolvers.ByPackageMapping resolving: com.xyz.model
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Called addAllDescriptors 
with null or empty descriptor map
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Get descriptor for: 
com.xyz.model.A found: null
[AbstractResolverClassCommand] Now in method: 
org.exolab.castor.xml.util.resolvers.ByDescriptorClass resolving: 
com.xyz.model.A
[ResolveHelpers] Ignored problem at loading class: com.xyz.model.ADescriptor 
through class loader: [EMAIL PROTECTED], exception: 
java.lang.ClassNotFoundException: com.xyz.model.ADescriptor
[ResolveHelpers] Ignored problem at loading class: 
com.xyz.model.descriptors.ADescriptor through class loader: [EMAIL PROTECTED], 
exception: java.lang.ClassNotFoundException: 
com.xyz.model.descriptors.ADescriptor
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Called addAllDescriptors 
with null or empty descriptor map
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Get descriptor for: 
com.xyz.model.A found: null
[AbstractResolverClassCommand] Now in method: 
org.exolab.castor.xml.util.resolvers.ByIntrospection resolving: com.xyz.model.A
[ResolveHelpers] Ignored problem at loading class: com.xyz.model.A through 
class loader: [EMAIL PROTECTED], exception: java.lang.ClassNotFoundException: 
com.xyz.model.A
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Called addAllDescriptors 
with null or empty descriptor map
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Get descriptor for: 
com.xyz.model.A found: null
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Adding class name to 
missing classes: com.xyz.model.A
[UnmarshalHandler] unable to find FieldDescriptor for 'A' in ClassDescriptor of 
A - ignoring extra element.
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Get descriptor for: 
com.xyz.model.NestedA found: [EMAIL PROTECTED]; descriptor for class: [null]; 
xml name: null
[XMLClassDescriptorResolverImpl$DescriptorCacheImpl] Get descriptor for: 
com.xyz.model.NestedA found: [EMAIL PROTECTED]; descriptor for class: [null]; 
xml name: null

+++ debugging output +++



-----Ursprüngliche Nachricht-----
Von: Werner Guttmann [mailto:[EMAIL PROTECTED]
Gesendet: Mi 30.07.2008 10:34
An: [email protected]
Betreff: Re: AW: [castor-user] unmarshalling equally named/xpath differing 
elements fails with classcastexception
 
I deployed one by chance the day before yesterday, but I do not think
that that should make a difference at all (as nothing relevant to your
area has changed).

Regards
Werner

Reinhard Weiss wrote:
> 
> i see, thanks. 
> is there a chance to get a recent [EMAIL PROTECTED]
> 
> regards, reinhard!
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Werner Guttmann [mailto:[EMAIL PROTECTED]
> Gesendet: Mo 28.07.2008 13:18
> An: [email protected]
> Betreff: Re: [castor-user] unmarshalling equally named/xpath differing 
> elements fails with classcastexception
>  
> Reinhard,
> 
> just ran your code (more or less without any modifications) against SVN
> trunk, and I am *not* getting any exceptions. In other words, the tests
> completes without any exceptions.
> 
> Werner
> 
> Reinhard Weiss wrote:
>> hi,
>>
>> i have an top level (document) element 'A' bound to java class 'TopLevelA'.
>> further there is a nested element named 'A' as well, which is bound to 
>> 'NestedA'.
>> (yes, the model is stupid, but i can't change...)
>>
>> on unmarshalling i get a 'NestedA' object instead of the expected 
>> 'TopLevelA'.
>>
>> i am using the 1.2.1-20080723.084025 snapshot available for download.
>>
>>
>>
>> in xsd that is:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
>> xmlns:xyz="http://www.xyz.com/"; targetNamespace="http://www.xyz.com/"; 
>> elementFormDefault="qualified" attributeFormDefault="unqualified">
>>      <xsd:element name="A" type="xyz:SomeType"/>
>>      <xsd:complexType name="AnotherType">
>>              <xsd:simpleContent>
>>                      <xsd:extension base="xsd:string">
>>                      </xsd:extension>
>>              </xsd:simpleContent>
>>      </xsd:complexType>
>>      <xsd:complexType name="SomeType">
>>              <xsd:sequence>
>>                      <xsd:element name="A" type="xyz:AnotherType" 
>> minOccurs="0" maxOccurs="unbounded"/>
>>              </xsd:sequence>
>>      </xsd:complexType>
>> </xsd:schema>
>>
>>
>>
>> the xml could be
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xyz:A xsi:schemaLocation="http://www.xyz.com/ A.xsd" 
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
>> xmlns:xyz="http://www.xyz.com/";>
>>      <xyz:A>hello world</xyz:A>
>> </xyz:A>
>>
>>
>>
>> the corresponding castor binding, which i wrote is:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <binding xmlns="http://www.castor.org/SourceGenerator/Binding"; 
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
>> xsi:schemaLocation="http://www.castor.org/SourceGenerator/Binding 
>> http://castor.org/binding.xsd"; defaultBindingType="element">
>>      <package>
>>              <name>com.xyz.model</name>
>>              <namespace>http://www.xyz/</namespace>
>>      </package>
>>      <elementBinding name="/A">
>>              <java-class name="TopLevelA"/>
>>      </elementBinding>
>>      <elementBinding name="/complexType:SomeType/A">
>>              <java-class name="NestedA"/>
>>      </elementBinding>
>> </binding>
>>
>>
>>
>> the test fails:
>>
>>     URL castrCdrUrl = 
>> getClass().getClassLoader().getResource("com/xyz/model/.castor.cdr");
>>     assertNotNull(castrCdrUrl);
>>     assertTrue(castrCdrUrl.toString().contains("classes"));
>>     assertTrue(new File(castrCdrUrl.toURI()).exists());
>>     
>>     XMLContext context = new XMLContext();
>>     context.addPackage("com.xyz.model");
>>     Unmarshaller unmarshaller = context.createUnmarshaller();
>>
>>     InputStream xmlStream = 
>> getClass().getClassLoader().getResourceAsStream("A.xml");
>>     assertNotNull(xmlStream);
>>    
>>     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
>>     DocumentBuilder builder = factory.newDocumentBuilder();
>>     InputSource is = new InputSource(xmlStream);
>>     Document xmlDocument = builder.parse(is);
>>
>>     TopLevelA topLevelA = (TopLevelA) unmarshaller.unmarshal(xmlDocument); 
>> // <- classcastexception
>>     
>>     assertNotNull(topLevelA);
>>     assertNotNull(topLevelA.getNestedA(0));
>>     assertEquals("hello world", topLevelA.getNestedA(0).getContent());
>>
>>      
>>
>> is this an issue to be reported via jira?
>>
>> regards,
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> DI Reinhard Weiss
>>
>> ANECON Software Design und Beratung G.m.b.H.
>>
>> Web:         http://www.anecon.com
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Zusätzliche Pflichtangaben von Kapitalgesellschaften gem. § 14 UGB:
>> FN166941b | Handelsgericht Wien | Firmensitz Wien
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> 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



<<winmail.dat>>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to