You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by "Pankov, Alexander" <Al...@softwareag.com> on 2007/01/26 17:41:16 UTC

SDO XMLHelper static scenario

Greetings all, 

I am relatively new to Tuscany SDO implementation but I am happy to see
full featured SDO.
In my case I have generated interfaces from xsd and I am trying to get
instances of those using XMLHelper and parsing xml document. I am using
the M2 jars and the code looks similar to:

DataObjectUtil.initRuntime();
SDOUtil.registerStaticTypes(XXXFactory.class);
XXX inst = (XXX)XMLHelper.INSTANCE.load(new
FileInputStream(path_to_schemaInstance_xml_doc)).getRootObject();

Here I get ClassCastException that AnyTypeDataObject can not be casted.
Is what I'm trying to do possible at all? If yes what am I doing wrong
and if the answer is no what is the recommended way of getting such
instances from xml documents? Is it a DAS responsibility?

It is pretty urgent to answer these questions so please drop any ideas
that come to mind.

Best Regards, 
Alexander

Re: SDO XMLHelper static scenario

Posted by Yang ZHONG <le...@gmail.com>.
Also, are SDOUtil.registerStaticTypes and XMLHelper.INSTANCE.load called on
the same Thread?
If yes, any call to Thread#setContextClassLoader between them?
ClassLoader plays an important role during types registrations such as
registerStaticTypes and queries such as load.

On 1/26/07, kelvin goodson <ke...@gmail.com> wrote:
>
> Alexander,
>
> on the face of it what you are doing seems fine,  but the symptom seems to
> suggest that the metadata for the incoming instance document can't be
> found.
> Are you sure that the type of the root element of the instance document
> correctly references a type in the namespace of the registered factory?
>
> Regards, kelvin.
>
>
> On 26/01/07, Pankov, Alexander <Al...@softwareag.com> wrote:
> >
> > Greetings all,
> >
> > I am relatively new to Tuscany SDO implementation but I am happy to see
> > full featured SDO.
> > In my case I have generated interfaces from xsd and I am trying to get
> > instances of those using XMLHelper and parsing xml document. I am using
> > the M2 jars and the code looks similar to:
> >
> > DataObjectUtil.initRuntime();
> > SDOUtil.registerStaticTypes(XXXFactory.class);
> > XXX inst = (XXX)XMLHelper.INSTANCE.load(new
> > FileInputStream(path_to_schemaInstance_xml_doc)).getRootObject();
> >
> > Here I get ClassCastException that AnyTypeDataObject can not be casted.
> > Is what I'm trying to do possible at all? If yes what am I doing wrong
> > and if the answer is no what is the recommended way of getting such
> > instances from xml documents? Is it a DAS responsibility?
> >
> > It is pretty urgent to answer these questions so please drop any ideas
> > that come to mind.
> >
> > Best Regards,
> > Alexander
> >
> >
>
>


-- 

Yang ZHONG

Re: SDO XMLHelper static scenario

Posted by kelvin goodson <ke...@gmail.com>.
Alexander,

  on the face of it what you are doing seems fine,  but the symptom seems to
suggest that the metadata for the incoming instance document can't be found.
Are you sure that the type of the root element of the instance document
correctly references a type in the namespace of the registered factory?

Regards, kelvin.


On 26/01/07, Pankov, Alexander <Al...@softwareag.com> wrote:
>
> Greetings all,
>
> I am relatively new to Tuscany SDO implementation but I am happy to see
> full featured SDO.
> In my case I have generated interfaces from xsd and I am trying to get
> instances of those using XMLHelper and parsing xml document. I am using
> the M2 jars and the code looks similar to:
>
> DataObjectUtil.initRuntime();
> SDOUtil.registerStaticTypes(XXXFactory.class);
> XXX inst = (XXX)XMLHelper.INSTANCE.load(new
> FileInputStream(path_to_schemaInstance_xml_doc)).getRootObject();
>
> Here I get ClassCastException that AnyTypeDataObject can not be casted.
> Is what I'm trying to do possible at all? If yes what am I doing wrong
> and if the answer is no what is the recommended way of getting such
> instances from xml documents? Is it a DAS responsibility?
>
> It is pretty urgent to answer these questions so please drop any ideas
> that come to mind.
>
> Best Regards,
> Alexander
>
>

Re: SDO XMLHelper static scenario

Posted by Yang ZHONG <le...@gmail.com>.
(Your static) types seems not picked up during load, so AnyTypeDataObject is
used instead of your generated class therefore ClassCastException.

On 1/26/07, Pankov, Alexander <Al...@softwareag.com> wrote:
>
> Greetings all,
>
> I am relatively new to Tuscany SDO implementation but I am happy to see
> full featured SDO.
> In my case I have generated interfaces from xsd and I am trying to get
> instances of those using XMLHelper and parsing xml document. I am using
> the M2 jars and the code looks similar to:
>
> DataObjectUtil.initRuntime();
> SDOUtil.registerStaticTypes(XXXFactory.class);
> XXX inst = (XXX)XMLHelper.INSTANCE.load(new
> FileInputStream(path_to_schemaInstance_xml_doc)).getRootObject();
>
> Here I get ClassCastException that AnyTypeDataObject can not be casted.
> Is what I'm trying to do possible at all? If yes what am I doing wrong
> and if the answer is no what is the recommended way of getting such
> instances from xml documents? Is it a DAS responsibility?
>
> It is pretty urgent to answer these questions so please drop any ideas
> that come to mind.
>
> Best Regards,
> Alexander
>
>


-- 

Yang ZHONG