[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    [jira] Commented: (XMLBEANS-346) Getting ClassCastException if the
From:       "J. Nessunnome (JIRA)" <xmlbeans-dev () xml ! apache ! org>
Date:       2007-11-06 0:31:50
Message-ID: 19334141.1194309110588.JavaMail.jira () brutus
[Download RAW message or body]


    [ 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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic