"xwiki" shouldn't be hardcoded. At the very least you can get it with XWikiContext.getMainXWiki() I think. A better solution would be to use a default wiki resolver to resolve the wiki name:

    resolver.resolver(defaultWikiName)