You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "rajasekhar juluri (JIRA)" <xm...@xml.apache.org> on 2007/10/22 13:33:05 UTC

[jira] Created: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Getting ClassCastException if the same root element exist in different XSD
--------------------------------------------------------------------------

                 Key: XMLBEANS-346
                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
             Project: XMLBeans
          Issue Type: Bug
          Components: XmlObject
    Affects Versions: Version 2.2
         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
            Reporter: rajasekhar juluri


HI All!
   
   I created the below XSD with two different packages.

   1)   Package structure as follows      
            -> test.xmlbeans.one 
            -> test.xmlbeans.two


     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

	<xs:element name="cXML">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="HEADER"/>
			
			</xs:sequence>
			
		</xs:complexType>
	</xs:element>
	
	<xs:element name="HEADER">
	       <xs:complexType>
	                <xs:sequence>	
		        	<xs:element ref="From"/>
				<xs:element ref="To"/>
				<xs:element ref="Sender"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
     </xs:schema> 


  
   2)   jar file generated successfully. While executing the below program i found ClassCastException.  
       
    java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
               at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
 
       
       This is the sample program 
            
           class TextXMlBeans{
                public static void main(String arg[]) trhows Exception{
                test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
             

               }
             }

 

Thanks,
Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Issue Comment Edited: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "J. Nessunnome (JIRA)" <xm...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540314 ] 

jeffb0 edited comment on XMLBEANS-346 at 11/5/07 4:35 PM:
-----------------------------------------------------------------

I believe I am encountering the same or a similar issue with XMLBeans 2.3. 

I am using several different schemas in my project (all without namespaces, and there is nothing I can do about that).  They are each compiled into a separate jar, each using a separate package, using the xmlbeans ant task.  I can only seem to successfully parse xml (using the <My Schema's Root Element Document>.Factory.parse(String xml) method) for the schema jar that is first in the classpath, otherwise I get a ClassCastException as described in this bug.

I've done some debugging, and I'm coming to the conclusion that the structure of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  Since my schemas do not have namespaces, each of jars I've built share some files that are identically named in identical packages.  Specifically, I've seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb file that seems to point to the actual schema for that jar.  If the factory uses this file to determine some of the classes it will use to parse the xml it has, this may explain the ClassCastException, as it's only looking at the first file on the classpath and not the correct one for the XML it has.

I think I would be beneficial to have a schema compiler feature to specify the location where these files are generated, like the Java package options, since sometimes the developer can't control if namespaces are used in his schemas or not.

      was (Author: jeffb0):
    I believe I am encountering the same or a similar issue with XMLBeans 2.3. 

I am using several different schemas in my project (all without namespaces, and there is nothing I can do about that).  They are each compiled into a separate jar, each using a separate package, using the xmlbeans ant task.  I can only seem to successfully parse xml (using the Factory.parse(String xml) method) for the schema jar that is first in the classpath, otherwise I get a ClassCastException as described in this bug.

I've done some debugging, and I'm coming to the conclusion that the structure of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  Since my schemas do not have namespaces, each of jars I've built share some files that are identically named in identical packages.  Specifically, I've seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb file that seems to point to the actual schema for that jar.  If the factory uses this file to determine some of the classes it will use to parse the xml it has, this may explain the ClassCastException, as it's only looking at the first file on the classpath and not the correct one for the XML.

I think I would be beneficial to have a schema compiler feature to specify the location where these files are generated, like the Java package options, since sometimes the developer can't control if namespaces are used in his schemas or not.
  
> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Commented: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "Dinesh Sub (JIRA)" <xm...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12560077#action_12560077 ] 

Dinesh Sub commented on XMLBEANS-346:
-------------------------------------

I also faced this issue for a while. We switched to JAXB (Sun's xml parser) and did not see that happening there. The generated jars via xjc are also much smaller in size and the ant task takes only fraction of the time. however we had to make some modifications to code like JAXB does not accept enums, have to use Lists instead of arrays etc.

> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Issue Comment Edited: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "J. Nessunnome (JIRA)" <xm...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540314 ] 

jeffb0 edited comment on XMLBEANS-346 at 11/5/07 4:40 PM:
-----------------------------------------------------------------

I believe I am encountering the same or a similar issue with XMLBeans 2.3. 

I am using several different schemas in my project (all without namespaces, and there is nothing I can do about that).  They are each compiled into a separate jar, each using a separate package, using the xmlbeans ant task.  I can only seem to successfully parse xml (using the <My Schema's Root Element Document>.Factory.parse(String xml) method) for the schema jar that is first in the classpath, otherwise I get a ClassCastException as described in this bug.  If I change the jar ordering, a different schema will be able to parse successfully, and the ClassCastException will be thrown for a different class.

I've done some debugging, and I'm coming to the conclusion that the structure of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  Since my schemas do not have namespaces, each of jars I've built share some files that are identically named in identical packages.  Specifically, I've seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb file that seems to point to the actual schema for that jar.  If the factory uses this file to determine some of the classes it will use to parse the xml it has, this may explain the ClassCastException, as it's only looking at the first file on the classpath and not the correct one for the XML it has.

I think I would be beneficial to have a schema compiler feature to specify the location where these files are generated, like the Java package options, since sometimes the developer can't control if namespaces are used in his schemas or not.

      was (Author: jeffb0):
    I believe I am encountering the same or a similar issue with XMLBeans 2.3. 

I am using several different schemas in my project (all without namespaces, and there is nothing I can do about that).  They are each compiled into a separate jar, each using a separate package, using the xmlbeans ant task.  I can only seem to successfully parse xml (using the <My Schema's Root Element Document>.Factory.parse(String xml) method) for the schema jar that is first in the classpath, otherwise I get a ClassCastException as described in this bug.

I've done some debugging, and I'm coming to the conclusion that the structure of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  Since my schemas do not have namespaces, each of jars I've built share some files that are identically named in identical packages.  Specifically, I've seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb file that seems to point to the actual schema for that jar.  If the factory uses this file to determine some of the classes it will use to parse the xml it has, this may explain the ClassCastException, as it's only looking at the first file on the classpath and not the correct one for the XML it has.

I think I would be beneficial to have a schema compiler feature to specify the location where these files are generated, like the Java package options, since sometimes the developer can't control if namespaces are used in his schemas or not.
  
> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Commented: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "Cezar Andrei (JIRA)" <xm...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12764198#action_12764198 ] 

Cezar Andrei commented on XMLBEANS-346:
---------------------------------------

Each compilation generates in the jar file a new SchemaTypeSystem in the form of .xsb files. Even if the java classes are in different packages, they do make use of data in the SchemaTypeSystems, if this data uses the same local names and the same namespaces it will colide and XMLBeans will find only the resource which uses that name first on the classpath, hence the exception.

In order to make use of such schemas (i.e. multiple schemas using the same qnames for different elements/attributes/types etc) you need to manage yourself the SchemaTypeSystems. See javadoc for class org.apache.xmlbeans.XmlBeans, methods:
    typeLoaderForClassLoader(ClassLoader loader)
    typeLoaderForResource(ResourceLoader resourceLoader)
    typeLoaderUnion(SchemaTypeLoader[] typeLoaders)
    typeSystemForClassLoader(ClassLoader loader, String stsName) 

1. create resource loader from the jar you target
resourceLoader1 = XMLBeans.resourceLoaderForPath(File[] path) 
2. load TypeSystem from the jar you target
   stl1 = XMLBeans. typeLoaderForResource(resourceLoader1);
3. use stl1 to parse/generate XmlObjects
  stl1.parse()  / stl1.newInstance()
4. do the same for the other schemas with a different set of resourceLoader and stl, make sure they don't mix.

It's a little more complicated but doable.

> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Commented: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "J. Nessunnome (JIRA)" <xm...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540314 ] 

J. Nessunnome commented on XMLBEANS-346:
----------------------------------------

I believe I am encountering the same or a similar issue. 

I am using several different schemas in my project (all without namespaces, and there is nothing I can do about that).  They are each compiled into a separate jar, each using a separate package, using the xmlbeans ant task.  I can only seem to successfully parse xml (using the Factory.parse(String xml) method) for the schema jar that is first in the classpath, otherwise I get a ClassCastException as described in this bug.

I've done some debugging, and I'm coming to the conclusion that the structure of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  Since my schemas do not have namespaces, each of jars I've built share some files that are identically named in identical packages.  Specifically, I've seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb file that seems to point to the actual schema for that jar.  If the factory uses this file to determine some of the classes it will use to parse the xml it has, this may explain the ClassCastException, as it's only looking at the first file on the classpath and not the correct one for the XML.

I think I would be beneficial to have a schema compiler feature to specify the location where these files are generated, like the Java package options, since sometimes the developer can't control if namespaces are used in his schemas or not.

> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Resolved: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "Cezar Andrei (JIRA)" <xm...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Cezar Andrei resolved XMLBEANS-346.
-----------------------------------

       Resolution: Won't Fix
    Fix Version/s: unspecified

There is nothing to be fixed at this point.

> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>             Fix For: unspecified
>
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Commented: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "Julien D. (JIRA)" <xm...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12578343#action_12578343 ] 

Julien D. commented on XMLBEANS-346:
------------------------------------

I've resolved this problem by specifying a different namespace in the second xsd, both schemas remain the same except the second one has a specific namespace.

> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Issue Comment Edited: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "J. Nessunnome (JIRA)" <xm...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540314 ] 

jeffb0 edited comment on XMLBEANS-346 at 11/5/07 4:32 PM:
-----------------------------------------------------------------

I believe I am encountering the same or a similar issue with XMLBeans 2.3. 

I am using several different schemas in my project (all without namespaces, and there is nothing I can do about that).  They are each compiled into a separate jar, each using a separate package, using the xmlbeans ant task.  I can only seem to successfully parse xml (using the Factory.parse(String xml) method) for the schema jar that is first in the classpath, otherwise I get a ClassCastException as described in this bug.

I've done some debugging, and I'm coming to the conclusion that the structure of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  Since my schemas do not have namespaces, each of jars I've built share some files that are identically named in identical packages.  Specifically, I've seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb file that seems to point to the actual schema for that jar.  If the factory uses this file to determine some of the classes it will use to parse the xml it has, this may explain the ClassCastException, as it's only looking at the first file on the classpath and not the correct one for the XML.

I think I would be beneficial to have a schema compiler feature to specify the location where these files are generated, like the Java package options, since sometimes the developer can't control if namespaces are used in his schemas or not.

      was (Author: jeffb0):
    I believe I am encountering the same or a similar issue. 

I am using several different schemas in my project (all without namespaces, and there is nothing I can do about that).  They are each compiled into a separate jar, each using a separate package, using the xmlbeans ant task.  I can only seem to successfully parse xml (using the Factory.parse(String xml) method) for the schema jar that is first in the classpath, otherwise I get a ClassCastException as described in this bug.

I've done some debugging, and I'm coming to the conclusion that the structure of the schemaorg_apache_xmlbeans.namespace package is probably responsible.  Since my schemas do not have namespaces, each of jars I've built share some files that are identically named in identical packages.  Specifically, I've seen that each jar has a schemaorg_apache_xmlbeans.namespace._nons.xmlns.xsb file that seems to point to the actual schema for that jar.  If the factory uses this file to determine some of the classes it will use to parse the xml it has, this may explain the ClassCastException, as it's only looking at the first file on the classpath and not the correct one for the XML.

I think I would be beneficial to have a schema compiler feature to specify the location where these files are generated, like the Java package options, since sometimes the developer can't control if namespaces are used in his schemas or not.
  
> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[jira] Commented: (XMLBEANS-346) Getting ClassCastException if the same root element exist in different XSD

Posted by "Nitin (JIRA)" <xm...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XMLBEANS-346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743373#action_12743373 ] 

Nitin commented on XMLBEANS-346:
--------------------------------

Hi, I am also hitting the same issue in the Latest Version of the XML Beans.
Please let me know if this isue is Resolved.

Is there any other option to make this work without changing the Namespace.

We cannot afford to change the Namespace as Server XML ae not getting parsed coreectly by changing the Namespace.

Best Regards,
Nitin

> Getting ClassCastException if the same root element exist in different XSD
> --------------------------------------------------------------------------
>
>                 Key: XMLBEANS-346
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-346
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: XmlObject
>    Affects Versions: Version 2.2
>         Environment: Windows xp operating system , jdk 1.4, WebLogic Server. 
>            Reporter: rajasekhar juluri
>
> HI All!
>    
>    I created the below XSD with two different packages.
>    1)   Package structure as follows      
>             -> test.xmlbeans.one 
>             -> test.xmlbeans.two
>      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
> 	<xs:element name="cXML">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="HEADER"/>
> 			
> 			</xs:sequence>
> 			
> 		</xs:complexType>
> 	</xs:element>
> 	
> 	<xs:element name="HEADER">
> 	       <xs:complexType>
> 	                <xs:sequence>	
> 		        	<xs:element ref="From"/>
> 				<xs:element ref="To"/>
> 				<xs:element ref="Sender"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
>      </xs:schema> 
>   
>    2)   jar file generated successfully. While executing the below program i found ClassCastException.  
>        
>     java.lang.ClassCastException: test.xmlbeans.one.CXMLDocumentImpl
>                at test.xmlbeans.two.CXMLDocument$Factory.parse(CXMLDocument.java)              
>  
>        
>        This is the sample program 
>             
>            class TextXMlBeans{
>                 public static void main(String arg[]) trhows Exception{
>                 test.xmlbeans.two.CXMLDocument cxml = test.xmlbeans.two.CXMLDocument.Factory.parse(new File(fileName), opt);
>              
>                }
>              }
>  
> Thanks,
> Rajasekhar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org