XWiki Administration won't load - XWiki/XWikiPreferences - velocitymacro error

We have an issue with our XWiki (was version 6.0.1, but we’ve upgraded it to 9.4) where the main author of almost all pages and scripts has been deleted. Now when we log in all we see is, “Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed. Check the rights of its last author or the parameters if it’s rendered from another script.]. Click on this message for details.” everywhere.

We are using a PostgreSQL Database for our XWiki, running on CentOS 7 with Tomcat 7, is there any way (maybe via the postgres DB or command line) that we can re-create this user so that we can get our XWiki operational without losing our data?

There are a few hundred pages of information stored in this XWiki DB that we cannot afford to lose. And I feel like if we can re-create the user who was set as the Author (and accidentally deleted) we can get this up and running again.

Any ideas? (Also, we cannot use the web UI to re-create the user, as we cannot navigate to the Preferences/Admin section of XWiki, due to the error messages)

Here’s an example of the error’s we’re seeing since this user was deleted… our home page looks like this:

Thanks in adv.

EDIT: I ran a SELECT * from xwikirecyclebin within Postgres and found the line that included deleting this user. Is there any way I can restore from there? Line 298 is “XWiki.User” that is the user that we want to restore…

Here is the screenshot of the Line 298 (the user we need) in the recycle bin

The user login name (alias) is actually the name of the user profile page, which is a wiki page. So if you know the user login name then you can access the user profile page directly. E.g.:

/xwiki/bin/view/XWiki/mflorea

If the user profile page has been deleted and it’s still in the recycle bin then you should get a link to restore it.

But this only restores the user profile page. You may still need to add the user back to the groups he was part of, especially the XWiki/XWikiAllGroup.

Hope this helps,
Marius

1 Like

The following XWiki extensions might help you:

1 Like

Note that this is an issue/regression that we introduced not long ago when we introduce the new Script permission. We need to do something about it since it’s a major pain. I’m looking for a JIRA issue or a discussion thread on this topic, will paste when I find it.

Thank you, I was able to use this to restore this users deleted account.

However, I am still getting all of the same errors, so I think I need to change this users’ permissions back to Admin, however, I do not know the direct link to the Users and Groups section, so I cannot navigate to it. Can someone show me what to put in the URL to get to that section?

Thank you for the links, I was able to add these extensions, but for them to help me I have to change the content creator/author page by page within my Wiki, which isn’t feasible in our environment. Is there an extension I can add that will allow me to change all pages that are owned by one user to a new user?

To fix this issue, I ended up restoring an older database from before the deletion of this admin user, between that, and deploying the new 9.4 enterprise WAR file we are now able to access our pages within our Wiki.

However, I now have a new problem. My account is an Administrator of the Wiki and yet, I cannot get to the Administration page to make changes. So I attempted to load https://wiki.ourdomain.com/bin/admin/XWiki/XWikiPreferences and was presented with this error:

https://pastebin.com/ru6qC3En

org.xwiki.rendering.macro.MacroExecutionException: Failed to evaluate Velocity Macro for content [##**************************************************************************************************
## Administration Sheet, used to display a common UI for some wiki features (presentation, users,
## groups, rights etc.) at global / space level and also for several applications.
##**************************************************************************************************
#if($xcontext.action == 'view')
  $response.sendRedirect($xwiki.getURL($doc.getFullName(), 'admin', $request.getQueryString()))##
#else
  $xwiki.jsx.use('XWiki.AdminSheet')##
  ## Construct the SSX parameter map:
  ## - One parameter for the color theme
  ## - Each custom ConfigurableClass can provide a custom icon to display in categories headings and 
  ##   thus we need to pass them to the SSX of the AdminSheet.
  #set ($parameterMap = {})
  #if ($themeDoc)
    #set ($discard = $parameterMap.put('colorTheme', $themeDocFullName)) 
  #end
  #foreach ($adminMenuCategory in $adminMenu)
    #set ($customIcon = $adminMenuCategory.categoryIcon)
    #if ("$!customIcon" != '')
      #set ($discard = $parameterMap.put("${adminMenuCategory.id}Icon", $customIcon)) 
    #end
  #end
  $xwiki.ssx.use('XWiki.AdminSheet', $parameterMap)##
  #if ("$!crtSectionId" != '' && $crtSectionId.indexOf('.') > 0 && $xwiki.exists($crtSectionId))
    #set ($sectionName = $xwiki.getDocument($crtSectionId).getDisplayTitle())
  #elseif ($crtSectionId != '' && $services.localization.get("admin.${crtSectionId.toLowerCase()}"))
    #set ($sectionName = $services.localization.render("admin.${crtSectionId.toLowerCase()}"))
  #elseif ("$!crtSectionId" != '')
    #set ($sectionName = $crtSectionId)
  #elseif ($crtCategoryId != '')
    #set ($sectionName = $services.localization.render("admin.${crtItemId}"))
  #elseif ($editor == 'globaladmin')
    #set ($sectionName = $services.localization.render('xe.admin.global'))
  #else
    #set ($sectionName = $currentSpace)
  #end

{{html}}
#template('hierarchy_macros.vm')
#hierarchy($tdoc, true)
{{/html}}

(% id="document-title" %)(((
  = $services.localization.render('admin.section.title', [$sectionName]) =
)))

  #verticalNavigation($adminMenu {'translationPrefix' : 'admin.', 'crtItemId' : "$!crtItemId", 'cssClass' : 'admin-menu'})
  ##-----------------------------------------
  ## admin-page display
  ##-----------------------------------------
    #if(!$crtSection && !$crtCategory)
      #admin_displayCategories($adminMenu 'admin.')
    #elseif (!$crtSection)
      #admin_displayCategory($crtCategory.children 'admin.')
    #else
      (% id="admin-page-content" %)(((
        ##------------------------------------------------------------------------------------------------------------
        ## The Administration allows editing other pages from different applications inside the admin context (UI)
        ##------------------------------------------------------------------------------------------------------------
        #if("$!{request.editmode}" == 'inline' && $xwiki.exists($section))
          $xcontext.setDisplayMode('edit')##

          {{html clean="false"}}{{include reference="XWiki.AdminInlineSheet" /}}{{/html}}
        #else
          #if($xwiki.exists("XWiki.Admin${section}Sheet"))
            ## Custom XE administration section

            {{include reference="XWiki.Admin${section}Sheet" /}}

          #elseif($xwiki.exists($section))
            {{html clean="false"}}#includeForm($section){{/html}}
          #end
        #end
        #if ($crtSection.configurable)
          {{include reference="XWiki.ConfigurableClass" /}}
        #end
      ))) ## admin-page-content
    #end
#end]
	at org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:139)
	at org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:52)
	at org.xwiki.rendering.macro.script.AbstractScriptMacro.evaluateBlock(AbstractScriptMacro.java:286)
	at org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:182)
	at org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:58)
	at org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transform(MacroTransformation.java:272)
	at org.xwiki.rendering.internal.transformation.DefaultRenderingContext.transformInContext(DefaultRenderingContext.java:183)
	at org.xwiki.rendering.internal.transformation.DefaultTransformationManager.performTransformations(DefaultTransformationManager.java:95)
	at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:263)
	at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:133)
	at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:58)
	at org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:96)
	at org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:39)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:239)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.applySheet(SheetDocumentDisplayer.java:219)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.maybeDisplayWithSheet(SheetDocumentDisplayer.java:174)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:111)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:52)
	at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:68)
	at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:42)
	at com.xpn.xwiki.script.display.DisplayScriptService.document(DisplayScriptService.java:141)
	at com.xpn.xwiki.script.display.DisplayScriptService.content(DisplayScriptService.java:204)
	at com.xpn.xwiki.script.display.DisplayScriptService.content(DisplayScriptService.java:163)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395)
	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384)
	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173)
	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
	at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:106)
	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluateInternal(DefaultVelocityEngine.java:259)
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:222)
	at com.xpn.xwiki.render.DefaultVelocityManager.evaluate(DefaultVelocityManager.java:361)
	at com.xpn.xwiki.internal.template.InternalTemplateManager.evaluateContent(InternalTemplateManager.java:796)
	at com.xpn.xwiki.internal.template.InternalTemplateManager.render(InternalTemplateManager.java:675)
	at com.xpn.xwiki.internal.template.InternalTemplateManager.lambda$renderFromSkin$0(InternalTemplateManager.java:650)
	at com.xpn.xwiki.internal.security.authorization.DefaultAuthorExecutor.call(DefaultAuthorExecutor.java:85)
	at com.xpn.xwiki.internal.template.InternalTemplateManager.renderFromSkin(InternalTemplateManager.java:649)
	at com.xpn.xwiki.internal.template.InternalTemplateManager.renderFromSkin(InternalTemplateManager.java:628)
	at com.xpn.xwiki.internal.template.InternalTemplateManager.render(InternalTemplateManager.java:614)
	at com.xpn.xwiki.internal.template.DefaultTemplateManager.render(DefaultTemplateManager.java:77)
	at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:2131)
	at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:180)
	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:463)
	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:210)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:112)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:127)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:134)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.xwiki.velocity.XWikiVelocityException: Failed to evaluate content with id [xwiki:XWiki.AdminSheet]
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:227)
	at com.xpn.xwiki.render.DefaultVelocityManager.evaluate(DefaultVelocityManager.java:361)
	at org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:131)
	... 96 more
Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'addAll' in  class java.util.ArrayList threw exception java.lang.NullPointerException at 43:xwiki:XWiki.AdminSheet[line 60, column 32]
	at org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:243)
	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:187)
	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
	at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:567)
	at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
	at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
	at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:216)
	at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:311)
	at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:230)
	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
	at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:216)
	at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:311)
	at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:230)
	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:106)
	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluateInternal(DefaultVelocityEngine.java:259)
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:222)
	... 98 more
Caused by: java.lang.NullPointerException

Any ideas as to what is causing this error?

Hi mcandeloro,

As far as I can tell, it seems that your WAR upgrade didn’t end up well : the velocity macro you provided in your exception is the macro that was used in XWiki 6.X (as a side note, the 9.4 macro for the Admin sheet is here and the 6.0.1 version is here).

When you upgraded to the 9.4 version, some API calls contained in this macro could not be parsed, as the APIs probably do not exists anymore (just guessing here).

Hey @caubin,

Okay, interesting, I wonder what caused it to fail. Maybe I could try re-deploying the WAR file? Or will I end up in the same position I’m in now?

Thank you for the links to the Admin sheet’s, except I can’t edit the current one to replace them, as the “Edit” button doesn’t even show.

It might not be the best idea to edit the template anyway : others template may fail after fixing this one and you probably won’t have the time to fix all of them :slight_smile:.

I think that the idea of re-deploying the WAR file could be worth, but I don’t have a very good knowledge on how to tweak the deployment process in order to fix your problem (maybe @vmassol will have more solutions about this).

1 Like

So indeed you restored a DB that doesn’t match the version of the WAR… You shouldn’t do that obviously :slight_smile:

So you have several choices:

  • force the Distribution Wizard to perform an upgrade of the pages, i.e tell it that the version of XWiki is actually 6.x or whatever version you used to restore your DB
  • import the All XAR in your wiki
  • revert your DB upgrade since it’s the not the right thing to do. It should be easy to fix a deleted user’s permissions with the scripts I gave you (or to recreate the user).
  • go to your XWiki 6.x wiki and export your content pages only (don’t export the xwiki default pages) and reinstall XWiki 9.4 and import those pages in it (making sure you don’t import default xwiki pages).

I highly recommend doing the 3rd option since the first 2 are complex and not guaranteed to work. The last option is a good solution too and depending on how much content and how many things you’ve touched on the default install it might be easy or hard to do.

Hope it helps

1 Like

Okay, yes, that is what sounds like happened to my installation.

Thank you for the options, I also agree in going with the last option, however, how can I export my content pages without the Administration section working?

(also note, this was an upgrade, so the old 6.0.1 version is no longer running)

Is there another way to back this content up? Maybe a way of doing so directly from within PostGres? I am able to see the DB via PgAdmin.

You could craft the export URL directly, see http://platform.xwiki.org/xwiki/bin/view/Features/Exports#HXARExport

1 Like

Great, thank you for the link and all the info! I was able to export all of my content to HTML without any issues.

Unfortunately, I deployed a new instance of Enterprise 9.4, created a new Postgres DB for it (left it empty this time) but the new instance is not accessible :(. We may look into an alternate Wiki application that is easier to setup and manage, if I can’t get this one up and running.

Right now when I try to access it I just get “HTTP ERROR 503” which doesn’t tell me much

HTML is not going to help you much. You need to export as XAR and reimport as XAR on the other instance.

I’m really sorry you got problems because it’s quite easy to install XWiki normally. My opinion is that you took the wrong way somehow and didn’t follow the tutorials for some reason or you have a very weird local setup. I’d love to know what went wrong and where though so that we can improve in the future.

Installing XWiki is as simple as (when you choose the most complex, manual install):

  • Unzip the XWiki WAR in your servlet container
  • Download your DB’s JDBC driver and copy it in the WAR’s WEB-INF/lib
  • Edit hibernate.cfg.xml and uncomment the section related to your DB and edit the URL connection to your DB

Ok we could make this simpler a bit by (and we want to do that):

  • Bundling all JDBC drivers for all DBs we officially support in WEB-INF/lib (provided we’re allowed to do that with their licenses)
  • Move the hibernate.cfg.xml to a step in the XWiki Installation Wizard when your start XWiki

But this shouldn’t make XWiki that hard and impossible to install.

(BTW we have APT and Docker-based installs too in case you want single click installs. There are also the cloud offering that exist that have XWiki installed for you.)

So it means there’s something more in what you’re doing or your setup that’s special and I’m curious to find out what it is.