DIIOP - copying an item class cast exception

I have a problem where I cannot copy a document that while using DIIOP (remote Java). The same code works fine when used without DIIOP.

This the structure of the code. If you need the exact code, I can post it as well. However, I think the devil is in the details in this problem, but more of a problem of understanding.

Document dCopyFrom…

Document dCopyTo = myDatabase.createDocument();

if (!MyConfig.m_bRemote)

{

//this works fine as it is not remote (DIIOP)

dCopyTo.copyItem( dCopyFrom.getFirstItem(“Body”) );

}

else

{

//here when using remote… I have recreate a document.

RichText bodyPart =dCopyFrom.getFirstItem(“Body”);

RichTextItem temprt = dCopyTo.createRichTextItem(“Body”);

//this causes it to cry about a class cast exception. I do instanceof checks as well. It is not the wrong class

//my guess is that due to it being remote, it does not have access to the data directly and appendrtitem does not try and go to the server.

temprt.appendRtIteam(bodyPart);

//as a workaround, I can get the text without formatting… but I want to get the full formatting (bold, tables…).

temprt.appendText( bodyPart.getUnformattedText ()).

//do other handling for attachments…

//this part works fine.

}

Any ideas on this?

Thanks,