Radu,
 
The names of the relevant .xsb resources for this XMLBean in the generated jar are:
 
schemaorg_apache_xmlbeans/type/URI_SHA_1_1DD80F3162A834D56F4BECF11C9343A1641FECC5/queryDefinition.xsb
schemaorg_apache_xmlbeans/type/URI_SHA_1_1DD80F3162A834D56F4BECF11C9343A1641FECC5/itemQueryDefinition.xsb
schemaorg_apache_xmlbeans/type/URI_SHA_1_1DD80F3162A834D56F4BECF11C9343A1641FECC5/changeRequestQueryDefinition.xsb
schemaorg_apache_xmlbeans/type/URI_SHA_1_1DD80F3162A834D56F4BECF11C9343A1641FECC5/fileQueryDefinition.xsb
 
There is no resource named:
 
    schemaorg_apache_xmlbeans/element/URI_SHA_1_1DD80F3162A834D56F4BECF11C9343A1641FECC5/item_2Dquery.xsb
 
Is this what you would expect?
 
Thanks,
 
-- Tellis


From: Tellis B. Ellis, IV [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 4:04 PM
To: [email protected]
Subject: RE: ArrayStoreException in get*Array() method in custom Ant task

Thanks for the help Radu! I'll test out the resource load using the xmlbean's classloader and let you know how it works out.
What puzzles me somewhat is why it (XMLBeans, the java classloader, etc) can't find the resource even if the resource is in the same jar as the
xmlbean class file. Have you encountered anything similar in Ant or elsewhere? Also, how did you know the name of resource it expects is
"schemaorg_apache_xmlbeans/element/URI_SHA_1_1DD80F3162A834D56F4BECF11C9343A1641FECC5/item_2Dquery.xsb"?
 
Thanks,
 
-- Tellis


From: Radu Preotiuc-Pietro [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 3:17 PM
To: [email protected]
Subject: RE: ArrayStoreException in get*Array() method in custom Ant task

Yeah, it does smell like one of those esoteric classloader issues. Do you also use substitution groups in this context? (looks like there probably are global element definitions corresponding to itenQueryDefinition, changeRequestQueryDefinition and fileQueryDefinition)
 
So what is happening is that XmlBeans doesn't have access to one of the generated resources so it can resolve the subst group. The resource name should be "schemaorg_apache_xmlbeans/element/URI_SHA_1_1DD80F3162A834D56F4BECF11C9343A1641FECC5/item_2Dquery.xsb" and the classloader should be com.commerce360.internal.cm.starteam.query.xml.QueryDefinitionSetXmlBean.class.getClassLoader() (hope I'm getting this right...). In order to debug this you can resource load that and see if ant makes it available to you, as a first step.
 
I'd appreciate it if you would let us know if get more info out of debugging this
Thanks,
Radu

From: Tellis B. Ellis, IV [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 21, 2006 9:24 AM
To: [email protected]
Subject: RE: ArrayStoreException in get*Array() method in custom Ant task

I left out some of the stacktrace:
 
java.lang.ArrayStoreException
        at java.lang.System.arraycopy(Native Method)
        at java.util.ArrayList.toArray(ArrayList.java:305)
        at com.commerce360.internal.cm.starteam.query.xml.impl.QueryDefinitionSetXmlBeanImpl.getQueryArray(QueryDefinitionSetXmlBe
anImpl.java:59)
 
 
Thanks,
 
-- Tellis

 

From: Tellis B. Ellis, IV [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 21, 2006 11:01 AM
To: [email protected]
Subject: ArrayStoreException in get*Array() method in custom Ant task

Fellow XMLBeans users,
 
I have an xmlbean and some code that uses the xmlbean. The code works as expected when launched from the java command-line
or launched via Ant's 'java' task. I wrote a simple Ant custom task to run the code. When the custom task is executed an ArrayStoreException is thrown in the bean's get*Array() method. I'm using XMLBeans 2.1.0 and Ant 1.6.4. Below is a snippet from the stacktrace:
 
     java.lang.ArrayStoreException
        at com.commerce360.internal.cm.starteam.query.xml.impl.QueryDefinitionSetXmlBeanImpl.getQueryArray(QueryDefinitionSetXmlBeanImpl.java:59)
 
The XSD fragment for the bean looks like this:
<xs:complexType name="queryDefinitionSet">
       
        <xs:sequence>
            <xs:element ref="query" maxOccurs="unbounded" minOccurs="0"/>
        </xs:sequence>
       
    </xs:complexType>
 
   <xs:complexType name="queryDefinition" abstract="true">
       
        <xs:sequence>  
           
            <xs:element name="id" type="xs:ID" maxOccurs="1"/>
 
        </xs:sequence>
       
    </xs:complexType>
   
    <xs:complexType name="itemQueryDefinition" abstract="true">
        <xs:complexContent>
            <xs:extension base="queryDefinition">         
                <xs:sequence>
 
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
   
    <xs:complexType name="changeRequestQueryDefinition">
        <xs:complexContent>
            <xs:extension base="itemQueryDefinition">         
                <xs:sequence>
 
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
   
    <xs:complexType name="fileQueryDefinition">
        <xs:complexContent>
            <xs:extension base="itemQueryDefinition">         
                <xs:sequence>
                   
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
   
    <xs:element name="query" type="queryDefinition"/>
The code generated for the xmlbean's getQueryArray() method looks like this:
 
public class QueryDefinitionSetXmlBeanImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements com.commerce360.internal.cm.starteam.query.xml.QueryDefinitionSetXmlBean
{
   
    public QueryDefinitionSetXmlBeanImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
   
    private static final javax.xml.namespace.QName QUERY$0 =
        new javax.xml.namespace.QName("http://www.360commerce.com/internal/starteam/query/xml", "query");
    private static final org.apache.xmlbeans.QNameSet QUERY$1 = org.apache.xmlbeans.QNameSet.forArray(
        new javax.xml.namespace.QName[] {
        new javax.xml.namespace.QName("http://www.360commerce.com/internal/starteam/query/xml", "item-query"),
        new javax.xml.namespace.QName("http://www.360commerce.com/internal/starteam/query/xml", "file-query"),
        new javax.xml.namespace.QName("http://www.360commerce.com/internal/starteam/query/xml", "change-request-query"),
        new javax.xml.namespace.QName("http://www.360commerce.com/internal/starteam/query/xml", "query"),
    });
   
   
    /**
     * Gets array of all "query" elements
     */
    public com.commerce360.internal.cm.starteam.query.xml.QueryDefinitionXmlBean[] getQueryArray()
    {
        synchronized (monitor())
        {
            check_orphaned();
            java.util.List targetList = new java.util.ArrayList();
            get_store().find_all_element_users(QUERY$1, targetList);
            com.commerce360.internal.cm.starteam.query.xml.QueryDefinitionXmlBean[] result = new 
                                          com.commerce360.internal.cm.starteam.query.xml.QueryDefinitionXmlBean[targetList.size()];
            targetList.toArray(result);
            return result;
        }
    }
   
     .....
     .....
     ......
 
}
 
 
 
The exception occurs at the 'targetList.toArray(result)' line. What's happening is that when the code is run as a custom ant task,
the class of the elements in the 'targetList' ArrayList is 'org.apache.xmlbeans.impl.values.XmlAnyTypeImpl' whereas when the same code
is successfully run as a command-line java app, the class is 'com.commerce360.internal.cm.starteam.query.xml.impl.ChangeRequestQueryDefinitionXmlBeanImpl'. I am using the same classpath
and input XML in both cases.
 
I did some googling and found another person who experienced the same exception but over RMI:
 
http://mail-archives.apache.org/mod_mbox/xmlbeans-user/200310.mbox/[EMAIL PROTECTED]
 
Does anyone have insight as to why the XMLBeans unmarshalling code would type my objects as XmlAnyTypeImpl when
run as a custom Ant task? This smells like one of those esoteric classloader issues and I suspect it requires a deeper knowlegde of XMLBeans
internals than I currently have to debug it.
 
Any help or insights would be appreciated.
 
Thanks,
 
-- Tellis
_______________________________________________________________________ This email message, together with any attachments, may contain of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated that may be confidential,  proprietary,  copyrighted  and/orprivileged, and is intended solely for the use of the individualentity named in this message. If you are not the intended recipient,have received this message in error, please immediately return thisemail and then delete it.

Reply via email to