On Sat, Jun 26, 2010 at 1:00 AM, Dennis Sosnoski <d...@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