Export & Import After Changed WebAppPath

I have an XWiki 11.1 installation below tomcat_ home\webapps\xwiki on a Windows10 desktop A and a freshly set up XWiki 11.1 installation below tomcat_home\webapps\marvin on another Windows10 desktop B. On B I’ve set xwiki.webapppath=marvin in xwiki.cfg. I exported the content of XWiki on A and imported it to the XWiki on B. Now on B the attachments are stored below permanent_directory/store/file/xwiki, but it seems that XWikiDocument.loadAttachements() expects the attachments below permanent_directory/store/file/marvin:

Caused by: com.xpn.xwiki.XWikiException: Error number 3002 in 3: The attachment [C:\kido\app\.marvin\store\file\marvin\1\5\eeb8a5779ea416f517621bd9244ab5\attachments\7\b\a19dd46704ef89490bd295809139b6\f.png] could not be found in the filesystem attachment store.
	at org.xwiki.store.legacy.store.internal.FilesystemAttachmentStore.loadAttachmentContent(FilesystemAttachmentStore.java:214)
	at com.xpn.xwiki.doc.XWikiAttachment.loadAttachmentContent(XWikiAttachment.java:1073)
	at com.xpn.xwiki.doc.XWikiDocument.loadAttachments(XWikiDocument.java:4217)
	at de.deka.marvin.internal.Archiver.archiveEntity(Archiver.java:239)
	at de.deka.marvin.internal.Archiver.archive(Archiver.java:149)
	... 168 more

Did I miss to configure a relevant property?

Hi @Kido

you mean by using Administration → export / import, or did you perform it another way?

I use a groovy script, which looks something like

    DocumentInstanceInputProperties iProps = new DocumentInstanceInputProperties()
    Map oProps = [
            packageBackupPack: Boolean.TRUE
    String filename = Util.encodeURI("Robo.${now}.xar", xcontext.getContext())
    XWikiServletResponse response = xcontext.getResponse()
    response.setHeader("Content-disposition", "attachment; filename=${filename}")
    oProps["target"] = response.getOutputStream()
    Job job = services.filter.instance.startExport(FilterStreamType.XWIKI_XAR_CURRENT, oProps, iProps)

BTW that’s a cool script! Would be awesome if you could share it on https://snippets.xwiki.org :slight_smile:

And you don’t have any issue if you add a new attachment, or you got the same error? It feels like a bug on our side, but it should behave the same way for newly added attachment and imported ones.

No, no problems. The point is: On import the attachement is stored as


and that’s fine so far. I can, e.g., view the attached image. But when my script calls loadAttachements() the attachement is assumed to be stored as


So it’s just the new WebAppPath that causes the problem somehow. Would be great if you could provide an educated guess, what could be wrong. If you cannot, I’ll set up a small test case…

See Export Selected Pages/Spaces

Nice, thanks!

The difference between those two paths is the name of the wiki. Looks like the first one is stored in the wiki xwiki (the main wiki) and the second one in the wiki marvin.

Yes, that’s what I tried to say: I changed the wepapppath from xwiki to marvin and now the attachements are looked for in the wrong place or imported to the wrong place. I do not know.

The change here have nothing to do with the webpath (from attachment point of view at least). It’s the id of the subwiki where the attachment is supposed to be stored, looks like the attachment is searched in wiki marvin instead of wiki xwiki. Maybe the URL you are using makes XWiki identify it as the wrong wiki (could be a bug in the URL parser used for the /download/ action).

Could you paste the complete error with all the caused by.

By the way make sure you properly set xwiki.webapppath property in xwiki.cfg. You don’t seems to mention it in previous messages.

I did in my very first message.

Indeed I missed it, then it’s something else.

My fault: I wrongly took the webapppath to provide the name for the main wiki, but the name of the main wiki seems to be hard-wired to “xwiki”.

It’s actually possible to change it but I wouldn’t recommend doing so: xwiki-platform/xwiki-platform-tools/xwiki-platform-tool-configuration-resources/src/main/resources/xwiki.cfg.vm at master · xwiki/xwiki-platform · GitHub