Attach a file via Java agent using embedObject
I am trying to attach a file via a Java agent using the embedObject method. The problem I'm having is that some documents are correctly attached but some aren't. I wonder if there is a size issue here, because the attachment works fine with small documents.
What I do is take information from, let's say, 20 documents, and create one report document that I attach to the body field of a rich text.
<<259 File does not exist >> is the execption that is raised after the following line: rtitem.embedObject(EmbeddedObject.EMBED_ATTACHMENT,null, fN, "Report");
I don't believe the problem is file size -- at least not directly. This looks like a timing issue that occurs because large files take longer to copy into the document than small files do. I believe there's some multithreading happening, such that embedObject returns control to your code before the copying is all done. Are you deleting each file immediately after the call to embedObject? If so, you're probably deleting them before Notes is done copying them.
Try saving the Notes document first. Then, after that succeeds, delete the files. If that doesn't help (or if I've guessed wrong about what you're doing) I suggest you call IBM support.
Do you have comments on this Ask the Expert question and response? Let us know.