You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Murphy, Eric" <er...@pfc.cfs.nrcan.gc.ca> on 2005/01/07 19:06:22 UTC

RE: ClassCastException using changeType()

Scott -
 
I had this problem which was caused by the situation described in my earlier
email titled ' Generated .jar files cause conflict' sent to the list on
Jan.5.  Essentially there were two objects of the same name and same
namespace in two different jar files.  I was asking for an object in one
package but an object with the same name but different package was being
returned.
 
Eric


  _____  

From: Scott Hinkelman [mailto:srh@us.ibm.com] 
Sent: Thursday, January 06, 2005 11:55 AM
To: user@xmlbeans.apache.org
Subject: ClassCastException using changeType()



Hello XMLBeans experts.
I essentially have the same situation discussed in the post [1] concerning
polymorphism.
However, I get a runtime ClassCastExecption during the operation containing
changeType().
Also, I have seen several uses of changeType() with parameters of
<class>.type, <class>.type(),
and as in the post <class>.schemaType(). The only one I can get to compile
is <class>.type, which
is where my exception occurs.

I am using JDK 1.5 and a svn pull of Trunk on 1/6/05.

If anyone can shed light on why I get that cast exception I would be very
appreciative.

[1]
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=user@xmlbeans.apache.org
<http://nagoya.apache.org/eyebrowse/ReadMsg?listName=user@xmlbeans.apache.or
g&msgId=1852352> &msgId=1852352

thanks,
Scott



Re: ClassCastException using changeType()

Posted by Scott Hinkelman <sr...@us.ibm.com>.




Girish/all,
Again thanks. But I after fully qualifying everything with the names
generated from the namespaces I still have the problem. I am very certain
that I don't have dup .xsb's or .class in the classpath..........

I can get by the cast exception by changing the casted return type to the
base abstract type (not surprising in of itself) - even while leaving the
parameter type on changetype() as it is (type to the
concrete).......instanceof then reveals the result to only be of the
abstract type and not concrete.........
I can new up a concrete independently using it's factory with no
problem.......but can't get changeType() to work on the abstract.....
The generated concrete interface does indeed extend the abstract
interface.......

?

Scott



                                                                           
             Girish Bhatia                                                 
             <bhatiagirish@gma                                             
             il.com>                                                    To 
                                       user@xmlbeans.apache.org            
             01/07/2005 12:20                                           cc 
             PM                                                            
                                                                   Subject 
                                       Re: ClassCastException using        
             Please respond to         changeType()                        
                   user                                                    
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




I have the similar error of ClassCastException. In my case, my jar
included two class files for the same type in two different
namespaces. My issue was resolved, when I used the full package name
with the class. for example. com.girsh.schema.Order order.

- Girish



On Fri, 7 Jan 2005 13:06:22 -0500, Murphy, Eric
<er...@pfc.cfs.nrcan.gc.ca> wrote:
>
> Scott -
>
> I had this problem which was caused by the situation described in my
earlier
> email titled ' Generated .jar files cause conflict' sent to the list on
> Jan.5.  Essentially there were two objects of the same name and same
> namespace in two different jar files.  I was asking for an object in one
> package but an object with the same name but different package was being
> returned.
>
> Eric
>
>
>  ________________________________
>  From: Scott Hinkelman [mailto:srh@us.ibm.com]
> Sent: Thursday, January 06, 2005 11:55 AM
> To: user@xmlbeans.apache.org
> Subject: ClassCastException using changeType()
>
>
>
>
> Hello XMLBeans experts.
> I essentially have the same situation discussed in the post [1]
concerning
> polymorphism.
> However, I get a runtime ClassCastExecption during the operation
containing
> changeType().
> Also, I have seen several uses of changeType() with parameters of
> <class>.type, <class>.type(),
> and as in the post <class>.schemaType(). The only one I can get to
compile
> is <class>.type, which
> is where my exception occurs.
>
> I am using JDK 1.5 and a svn pull of Trunk on 1/6/05.
>
> If anyone can shed light on why I get that cast exception I would be very
> appreciative.
>
> [1]
>
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=user@xmlbeans.apache.org&msgId=1852352

>
> thanks,
> Scott
>

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


Re: ClassCastException using changeType()

Posted by Girish Bhatia <bh...@gmail.com>.
I have the similar error of ClassCastException. In my case, my jar
included two class files for the same type in two different
namespaces. My issue was resolved, when I used the full package name
with the class. for example. com.girsh.schema.Order order.

- Girish



On Fri, 7 Jan 2005 13:06:22 -0500, Murphy, Eric
<er...@pfc.cfs.nrcan.gc.ca> wrote:
>  
> Scott - 
>   
> I had this problem which was caused by the situation described in my earlier
> email titled ' Generated .jar files cause conflict' sent to the list on
> Jan.5.  Essentially there were two objects of the same name and same
> namespace in two different jar files.  I was asking for an object in one
> package but an object with the same name but different package was being
> returned. 
>   
> Eric
>  
>  
>  ________________________________
>  From: Scott Hinkelman [mailto:srh@us.ibm.com] 
> Sent: Thursday, January 06, 2005 11:55 AM
> To: user@xmlbeans.apache.org
> Subject: ClassCastException using changeType()
> 
>  
>  
> 
> Hello XMLBeans experts.
> I essentially have the same situation discussed in the post [1] concerning
> polymorphism.
> However, I get a runtime ClassCastExecption during the operation containing
> changeType().
> Also, I have seen several uses of changeType() with parameters of
> <class>.type, <class>.type(),
> and as in the post <class>.schemaType(). The only one I can get to compile
> is <class>.type, which
> is where my exception occurs.
> 
> I am using JDK 1.5 and a svn pull of Trunk on 1/6/05.
> 
> If anyone can shed light on why I get that cast exception I would be very
> appreciative.
> 
> [1]
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=user@xmlbeans.apache.org&msgId=1852352
> 
> thanks,
> Scott
>

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


RE: ClassCastException using changeType()

Posted by Scott Hinkelman <sr...@us.ibm.com>.




Eric/all,
thanks, but inspecting the classpath I am sure I only have one jar with the
abstract and concrete .class and .xsb files. I am building the single jar
in a separate ant step and using the -srconly flag when initially executing
the java org.apache.xmlbeans.impl.tool.SchemaCompiler (the scomp script
calls this) .xsd compiler. There are no dups in my single jar related to
XMLBean code in the classpath. Both the abstract and concrete types are
defined in different namespaces in each xsd file.

I am struggling with ploymorphism support using the changeType() call.
I have two schemas, snips as the following.

An abstract complex type:

<xs:complexType name="AbstractType" abstract="true">
    <xs:sequence>
      <xs:element name="Description" minOccurs="0">
.................
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:complexType>

A concrete extension:

<xs:complexType name="ConcreteType">
    <xs:complexContent>
      <xs:extension base="x:namespaceforabstract">
        <xs:sequence>
......................
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
</xs:complexType>

It is my understanding that I should be able to do the following:

1) add a new abstract type into the container element of which holds
elements typed as the abstract type, similar to:
AbstractType  abstract_type=AbstractContainer.addNewAbstract();

2)use changeType on the new abstract type to obtain a new concrete type,
similar to:
ConcreteType
concrete_type=(ConcreteType)abstract_type.changeType(ConcreteType.type);

I would to then expect to have a concrete type with the xsi:type attribute
generated.

I am getting a ClassCastException at runtime.  am I understanding this
correctly?
any help is appreciated, thank you.

Scott



                                                                           
             "Murphy, Eric"                                                
             <erimurph@pfc.cfs                                             
             .nrcan.gc.ca>                                              To 
                                       "'user@xmlbeans.apache.org'"        
             01/07/2005 12:06          <us...@xmlbeans.apache.org>          
             PM                                                         cc 
                                                                           
                                                                   Subject 
             Please respond to         RE: ClassCastException using        
                   user                changeType()                        
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Scott -

I had this problem which was caused by the situation described in my
earlier email titled ' Generated .jar files cause conflict' sent to the
list on Jan.5.  Essentially there were two objects of the same name and
same namespace in two different jar files.  I was asking for an object in
one package but an object with the same name but different package was
being returned.

Eric

 From: Scott Hinkelman [mailto:srh@us.ibm.com]
 Sent: Thursday, January 06, 2005 11:55 AM
 To: user@xmlbeans.apache.org
 Subject: ClassCastException using changeType()



 Hello XMLBeans experts.
 I essentially have the same situation discussed in the post [1] concerning
 polymorphism.
 However, I get a runtime ClassCastExecption during the operation
 containing changeType().
 Also, I have seen several uses of changeType() with parameters of
 <class>.type, <class>.type(),
 and as in the post <class>.schemaType(). The only one I can get to compile
 is <class>.type, which
 is where my exception occurs.

 I am using JDK 1.5 and a svn pull of Trunk on 1/6/05.

 If anyone can shed light on why I get that cast exception I would be very
 appreciative.

 [1]
 http://nagoya.apache.org/eyebrowse/ReadMsg?listName=user@xmlbeans.apache.org&msgId=1852352


 thanks,
 Scott