You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Dennis Sosnoski <dm...@sosnoski.com> on 2010/06/26 01:00:02 UTC

Re: [JiBX DataBinding] An issue when feeding the XMLStreamReader to JiBX framework

Daniel Kulp wrote:
> On Friday 25 June 2010 12:44:49 pm Dennis Sosnoski wrote:
>   
>> Hi Nilupa,
>>
>> Looking at the stack trace, I'm wondering how you're passing the
>> XMLStreamReader to JiBX. The way the code is set up, you need to create
>> the StAXReaderWrapper *before* you reach the start tag of the element
>> that's going to be processed by JiBX (so in the case of processing a
>> SOAP message body, you'd need to do this while the XMLStreamReader is
>> positioned on the Body start tag). If you create the StAXReaderWrapper
>> when you're already positioned at the start tag of the element it looks
>> like it would cause this problem when you reach the end tag.
>>     
>
> Hmm..   that's likely going to be a problem if we do the full "use wrappers" 
> approach.   We need to get the element nam to be able figure out the operation 
> name and map that to the right class to use and such. Thus, by the time the 
> databinding gets it, it would be positioned AT the start element, not before 
> it.
>
> Dan
>   

Ok, sounds like the approach mentioned below is the one we'll need to try.

>  > If you can't take this approach with CXF I can change the
>   
>> StAXReaderWrapper to give you a workaround. It should be enough to just
>> make the startTag() method public, so that after constructing the
>> StAXReaderWrapper you call this method to initialize the state for the
>> current element start tag.
>>     

Nilupa, I've updated JiBX CVS with this change and posted new 
1.2.3-SNAPSHOT jars to the maven1 repository at 
http://jibx.sourceforge.net/maven/jibx/jars/ Try adding the call to 
startTag() after constructing the StAXReaderWrapper, it should get you 
past the problem.

  - Dennis

Re: [JiBX DataBinding] An issue when feeding the XMLStreamReader to JiBX framework

Posted by Nilupa Bandara <ni...@gmail.com>.
On Tue, Jun 29, 2010 at 10:11 PM, Dennis Sosnoski <dm...@sosnoski.com> wrote:

> Never mind, I think I found the issue. I've changed the StAXReaderWrapper
> code so that you should no longer need to call startTag() at all and have
> changed that back to a private method. Please try the latest 1.2.3-SNAPSHOT
> jars and verify that this now works.
>

Yes it works fine now :-). Thanks for fix !!

By the way, I've started working on the JiBX code generation API and
implementing a DataBidingProfile for JiBX databinding implementation. I will
 post my progress as soon as I get to work to some extent and post any
questions that might occur along the way.

Thanks & Best Regards

Nilupa



> Thanks again,
>
>  - Dennis
>
>
>
> Dennis Sosnoski wrote:
>
>> Nilupa Bandara wrote:
>>
>>> On Sat, Jun 26, 2010 at 1:00 AM, Dennis Sosnoski <dm...@sosnoski.com>
>>> wrote:
>>> ...
>>>
>>>
>>>> Nilupa, I've updated JiBX CVS with this change and posted new
>>>> 1.2.3-SNAPSHOT jars to the maven1 repository at
>>>> http://jibx.sourceforge.net/maven/jibx/jars/ Try adding the call to
>>>> startTag() after constructing the StAXReaderWrapper, it should get you
>>>> past
>>>> the problem.
>>>>
>>>>
>>>>
>>>>
>>> Hi,
>>>
>>> Still it gives an error even if  I call the startTag() after
>>> instantiating
>>> the StAXReaderWrapper  object[1]. However if I call same method twice
>>> startTag(), it works[2]
>>>
>>>
>>
>> It sounds like the code is somehow reading beyond the end of the element
>> you're having JiBX unmarshal, to the enclosing element end tag. I don't know
>> why this would be occurring.
>>
>> Can you send me the stack traces you get when (1) you don't call
>> wrapper.startTag() at all, and when (2) you just call it once? That may help
>> me determine what's going wrong.
>>
>> Thanks,
>>
>>  - Dennis
>>
>>


-- 
Nilupa Bandara

Re: [JiBX DataBinding] An issue when feeding the XMLStreamReader to JiBX framework

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Never mind, I think I found the issue. I've changed the 
StAXReaderWrapper code so that you should no longer need to call 
startTag() at all and have changed that back to a private method. Please 
try the latest 1.2.3-SNAPSHOT jars and verify that this now works.

Thanks again,

  - Dennis


Dennis Sosnoski wrote:
> Nilupa Bandara wrote:
>> On Sat, Jun 26, 2010 at 1:00 AM, Dennis Sosnoski <dm...@sosnoski.com> 
>> wrote:
>> ...
>>  
>>> Nilupa, I've updated JiBX CVS with this change and posted new
>>> 1.2.3-SNAPSHOT jars to the maven1 repository at
>>> http://jibx.sourceforge.net/maven/jibx/jars/ Try adding the call to
>>> startTag() after constructing the StAXReaderWrapper, it should get 
>>> you past
>>> the problem.
>>>
>>>
>>>     
>> Hi,
>>
>> Still it gives an error even if  I call the startTag() after 
>> instantiating
>> the StAXReaderWrapper  object[1]. However if I call same method twice
>> startTag(), it works[2]
>>   
>
> It sounds like the code is somehow reading beyond the end of the 
> element you're having JiBX unmarshal, to the enclosing element end 
> tag. I don't know why this would be occurring.
>
> Can you send me the stack traces you get when (1) you don't call 
> wrapper.startTag() at all, and when (2) you just call it once? That 
> may help me determine what's going wrong.
>
> Thanks,
>
>  - Dennis
>

Re: [JiBX DataBinding] An issue when feeding the XMLStreamReader to JiBX framework

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Nilupa Bandara wrote:
> On Sat, Jun 26, 2010 at 1:00 AM, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> ...
>   
>> Nilupa, I've updated JiBX CVS with this change and posted new
>> 1.2.3-SNAPSHOT jars to the maven1 repository at
>> http://jibx.sourceforge.net/maven/jibx/jars/ Try adding the call to
>> startTag() after constructing the StAXReaderWrapper, it should get you past
>> the problem.
>>
>>
>>     
> Hi,
>
> Still it gives an error even if  I call the startTag() after instantiating
> the StAXReaderWrapper  object[1]. However if I call same method twice
> startTag(), it works[2]
>   

It sounds like the code is somehow reading beyond the end of the element 
you're having JiBX unmarshal, to the enclosing element end tag. I don't 
know why this would be occurring.

Can you send me the stack traces you get when (1) you don't call 
wrapper.startTag() at all, and when (2) you just call it once? That may 
help me determine what's going wrong.

Thanks,

  - Dennis

Re: [JiBX DataBinding] An issue when feeding the XMLStreamReader to JiBX framework

Posted by Nilupa Bandara <ni...@gmail.com>.
On Sat, Jun 26, 2010 at 1:00 AM, Dennis Sosnoski <dm...@sosnoski.com> wrote:

> Daniel Kulp wrote:
>
>> On Friday 25 June 2010 12:44:49 pm Dennis Sosnoski wrote:
>>
>>
>>> Hi Nilupa,
>>>
>>> Looking at the stack trace, I'm wondering how you're passing the
>>> XMLStreamReader to JiBX. The way the code is set up, you need to create
>>> the StAXReaderWrapper *before* you reach the start tag of the element
>>> that's going to be processed by JiBX (so in the case of processing a
>>> SOAP message body, you'd need to do this while the XMLStreamReader is
>>> positioned on the Body start tag). If you create the StAXReaderWrapper
>>> when you're already positioned at the start tag of the element it looks
>>> like it would cause this problem when you reach the end tag.
>>>
>>>
>>
>> Hmm..   that's likely going to be a problem if we do the full "use
>> wrappers" approach.   We need to get the element nam to be able figure out
>> the operation name and map that to the right class to use and such. Thus, by
>> the time the databinding gets it, it would be positioned AT the start
>> element, not before it.
>>
>> Dan
>>
>>
>
> Ok, sounds like the approach mentioned below is the one we'll need to try.
>
>
>   > If you can't take this approach with CXF I can change the
>>
>>
>>> StAXReaderWrapper to give you a workaround. It should be enough to just
>>> make the startTag() method public, so that after constructing the
>>> StAXReaderWrapper you call this method to initialize the state for the
>>> current element start tag.
>>>
>>>
>>
> Nilupa, I've updated JiBX CVS with this change and posted new
> 1.2.3-SNAPSHOT jars to the maven1 repository at
> http://jibx.sourceforge.net/maven/jibx/jars/ Try adding the call to
> startTag() after constructing the StAXReaderWrapper, it should get you past
> the problem.
>
>
Hi,

Still it gives an error even if  I call the startTag() after instantiating
the StAXReaderWrapper  object[1]. However if I call same method twice
startTag(), it works[2]


Thanks,
Nilupa


[1] Gives same error.

UnmarshallingContext ctx =
(UnmarshallingContext)factory.createUnmarshallingContext();
StAXReaderWrapper wrapper = new StAXReaderWrapper(reader, "Data-element",
true);
wrapper.startTag();
ctx.setDocument(wrapper);
ctx.toTag();
return ctx;


[2] Works fine

UnmarshallingContext ctx =
(UnmarshallingContext)factory.createUnmarshallingContext();
StAXReaderWrapper wrapper = new StAXReaderWrapper(reader, "Data-element",
true);
wrapper.startTag();
wrapper.startTag(); // calling startTag() twice, prevents the error
ctx.setDocument(wrapper);
ctx.toTag();
return ctx;





>  - Dennis
>



-- 
Nilupa Bandara