I am really frustrated with this now. I cannot get to save an attachment to a document although all works well on my local xwiki instance 1.6.1. As discussed in post "Re: [xwiki-users] groovy.lang.MissingMethodException - Nosignatureof method" and suggested by Denis Gervalle -def attP = doc.getAttachment(filenameToSavaAs) -if( !attP ) attP = new com.xpn.xwiki.doc.XWikiAttachment(doc,filenameToSavaAs) -doc.getAttachmentList().add(attP) -attP.content = imgAsBites -attP.author = context.user -// attP.comment = 'comments for your attachement if you want' -doc.saveAttachmentContent(attP,context) This however generates a new instance of the same file every time the code is run. This is the same on v1.6 and 1.7 that myxwiki runs. I've tried doing doc.getAttachmentList().add(doc.getAttachmentList().indexOf(attP),attP) but this fails saying that the index is -1. Also on the 1.6 version if I restart glassFish only one file instance is left in the attachment area. Clears the chache. But the code below works perfect on my local instance yet on myxwiki the attached file disappears after a while cos it is not stored permanently. //convert from doc.XWikiDocument to api.Document com.xpn.xwiki.api.Document apidoc = new com.xpn.xwiki.api.Document(doc,context); //get image from url as byte[] def imgAsBites = xwiki.getURLContentAsBytes("http://www.websequencediagrams.com/index.php "+umlImage, context); //add to api document (this doesn't save it permanently) def attImg = apidoc.addAttachment(filenameToSavaAs, imgAsBites); //this saves it on v1.6 doc.saveAttachmentContent(attImg, context) ; //remove existing error file //there seams to be a bug in deleteAttachment so will overwrite existing file with a blank one def att = doc.getAttachment("ErrorLogUML.txt"); if( att ) { def attString = "No ERRORS"; def attByteArr = attString.getBytes(); def attTxt = apidoc.addAttachment("ErrorLogUML.txt", attByteArr); doc.saveAttachmentContent(attTxt, context) ; } //end apidoc.save(); -------------------------------------------------------- NOTICE This message and any files transmitted with it is intended for the addressee only and may contain information that is confidential or privileged. Unauthorised use is strictly prohibited. If you are not the addressee, you should not read, copy, disclose or otherwise use this message, except for the purpose of delivery to the addressee. Any views or opinions expressed within this e-mail are those of the author and do not necessarily represent those of Coventry University.