Null IMarshallingContext in pre-set method

View: New views
2 Messages — Rating Filter:   Alert me  

Null IMarshallingContext in pre-set method

by Quecas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Everyone,

I am experincing, which I tyhink is odd behaviour in a pre-set method (collection element). The IMarshallingContext passed the method is always null.

Before unmarshalling a document I call setUserContext(obj) and I have verified that "obj" is NOT null.

The class where I am trying to retrieve "obj" is a "fake" container for a very large collection which does not have a name property since it is a repeating sequence - does this make any difference?

It seems that somewhere, context.reset() is being called and I have verified that it is not in my code.

P.S.
what are best practices for passing around non-static data?

Thanks
Jorge

Re: Null IMarshallingContext in pre-set method

by Quecas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I found a post on this forum that had a solution that I could have sworn I tried yesterday (on different machine). I trried this and now it works:

  IUnmarshallingContext ucontext = factory.createUnmarshallingContext();
  ucontext.setDocument(bis, "UTF-8");
  ucontext.setUserContext(obj);
  ucontext.unmarshallElement();

instead of:

  IUnmarshallingContext ucontext = factory.createUnmarshallingContext();
  ucontext.setUserContext(obj);
  ucontext.unmarshallDocument(bis, "UTF-8");

Thanks
Jorge


Quecas wrote:
Hi Everyone,

I am experincing, which I tyhink is odd behaviour in a pre-set method (collection element). The IMarshallingContext passed the method is always null.

Before unmarshalling a document I call setUserContext(obj) and I have verified that "obj" is NOT null.

The class where I am trying to retrieve "obj" is a "fake" container for a very large collection which does not have a name property since it is a repeating sequence - does this make any difference?

It seems that somewhere, context.reset() is being called and I have verified that it is not in my code.

P.S.
what are best practices for passing around non-static data?

Thanks
Jorge
LightInTheBox - Buy quality products at wholesale price!