Execution of Velocity Macro fails with any user (admin or not admin) whenever I click on the PROFILE menu

Hello everybody:

I am a Linux System Administrator who works for a Spanish private IT company. I am in charge of the admnistration of the server where an Xwiki release is installed. I also am the admin of the application.
Once I am logged into the Xwiki app with my user, each time I try to click on the PROFILE:<user_name> link, which is placed in the right-top of the web form, I get the following error:

Failed to execute the {velocity] macro

This is happening from March of the current year, the 8th. Looking into the server (CentOS Linux release 6.5), I see all the services/processes running up, but I have realized that the Mysql service was restarted just that day.
In one of the answers given by V.Massol, he points out that it may be a communication problem between the application layer (Tomcat) and MySQL. I’m thinking in stopping and starting both processes (tomcat first and mySql then), but I am not sure whether this will work or not.
Can anybody help me with this please? This error occurs with all the users, not only with my user.

Find below the code associated with the error message:

org.xwiki.rendering.macro.MacroExecutionException: Failed to evaluate Velocity Macro for content [#set ($obj = $doc.getObject('XWiki.XWikiUsers'))
#if (!$obj)
= {{translation key="xe.admin.users.sheet"/}} =

{{info}}{{translation key="xe.admin.users.applyonusers"/}}{{/info}}
#else
  #set($temp = $xwiki.ssx.use('WikiManager.UserWikiSheet'))
  #set($temp = $xwiki.jsx.use('WikiManager.UserWikiSheet'))
  #set($temp = $doc.use($obj))
  #set ($currentUser = $xcontext.user)
  #if (!$currentUser.startsWith("${services.wiki.mainWikiId}:"))
    #set ($currentUser = "${services.wiki.mainWikiId}:${currentUser}")
  #end
  #set($documentUser = $doc.prefixedFullName)
  #set($isMyProfile = ($currentUser == $documentUser))
  {{html clean='false'}}
  <div class='half column'>
    <div class='profile-section highlighted-profile-section'>
      <h1>$services.localization.render('platform.wiki.users.profile.joinedwikis.label')</h1>
      #set ($joinedWikis = [])
      #set ($wikis = $services.wiki.getAll())
      #foreach ($wiki in $wikis)
        #if($services.wiki.user.isMember($currentUser, $wiki.id))
          #set($temp = $joinedWikis.add($wiki))
        #end
      #end
      #if ($joinedWikis.size() == 0)
        <span>#if ($isMyProfile)$services.localization.render('platform.wiki.users.profile.joinedwikis.notMemberOfAnyWiki')#{else}$services.localization.render('platform.wiki.users.profile.joinedwikis.userNotMemberOfAnyWiki')#end</span>
      #else
        <ul id='wikis'>
        #foreach ($wiki in $joinedWikis)
          <li id='$wiki.id'>
            <span class='wikiHomepage'><a href='$xwiki.getURL($wiki.mainPageReference)'>$wiki.prettyName</a></span>
            <span class='wikiActivity'><a href='javascript:void(0)'>$services.localization.render('platform.wiki.users.profile.activity.show') &#187;</a></span>
          </li>
        #end
        </ul>
      #end
    </div>
  </div>
  <div id='wikiActivity' class='half column'>
    <div id='wikiActivityColumn'>
    </div>
  </div>
  <div class="clearfloats">&nbsp;</div>
  {{/html}}
#end## User object exists]
	at org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:131)
	at org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:50)
	at org.xwiki.rendering.macro.script.AbstractScriptMacro.evaluateBlock(AbstractScriptMacro.java:302)
	at org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:198)
	at org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:59)
	at org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transformOnce(MacroTransformation.java:191)
	at org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transform(MacroTransformation.java:132)
	at org.xwiki.rendering.internal.transformation.DefaultTransformationManager.performTransformations(DefaultTransformationManager.java:87)
	at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:252)
	at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:125)
	at org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:55)
	at org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:80)
	at org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:38)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:253)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.displayAsSheetAuthor(SheetDocumentDisplayer.java:232)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.applySheet(SheetDocumentDisplayer.java:210)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.maybeDisplayWithSheet(SheetDocumentDisplayer.java:164)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:102)
	at org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:50)
	at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:67)
	at org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:41)
	at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:993)
	at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:972)
	at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1003)
	at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:603)
	at sun.reflect.GeneratedMethodAccessor312.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	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.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.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.evaluate(DefaultVelocityEngine.java:228)
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:187)
	at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:105)
	at com.xpn.xwiki.internal.template.DefaultPrivilegedTemplateRenderer.evaluate(DefaultPrivilegedTemplateRenderer.java:125)
	at com.xpn.xwiki.internal.template.DefaultPrivilegedTemplateRenderer.evaluateTemplate(DefaultPrivilegedTemplateRenderer.java:75)
	at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:1687)
	at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1627)
	at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:918)
	at sun.reflect.GeneratedMethodAccessor153.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	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.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.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.evaluate(DefaultVelocityEngine.java:228)
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:187)
	at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:105)
	at com.xpn.xwiki.internal.template.DefaultPrivilegedTemplateRenderer.evaluate(DefaultPrivilegedTemplateRenderer.java:125)
	at com.xpn.xwiki.internal.template.DefaultPrivilegedTemplateRenderer.evaluateTemplate(DefaultPrivilegedTemplateRenderer.java:75)
	at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:1687)
	at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:166)
	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:304)
	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:129)
	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:617)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:121)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:144)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:66)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:429)
	at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:384)
	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
	at java.lang.Thread.run(Thread.java:662)
Caused by: org.xwiki.velocity.XWikiVelocityException: Failed to evaluate content with id [xwiki:XWiki.XWikiUserSheet]
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:247)
	at org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:187)
	at org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:124)
	... 107 more
Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'isMember' in  class org.xwiki.wiki.user.script.WikiUserManagerScriptService threw exception java.lang.NullPointerException at xwiki:XWiki.XWikiUserSheet[line 23, column 25]
	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.evaluate(ASTReference.java:530)
	at org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExpression.java:62)
	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:85)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
	at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:420)
	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.evaluate(DefaultVelocityEngine.java:228)
	... 109 more
Caused by: java.lang.NullPointerException

The problem is that your stack trace is cut in your message… and we need the root cause to help you out. :slight_smile:

Hello Vincent,

Thanks a lot for your quick response!! I understand perfectly what you say but, how can I get the full stack trace? In the catalina.out log file there is no trace about this error (I already have checked it). Anyway, what could be, in your opinnion, the root cause? Thank you again and kind regards,

Ignacio.

It is in the logs where you found the start of the stack trace. You just need to copy it fully. A stack trace cannot end by:

Thanks

Good morning Vincent,

Thanks again for your support. The thing is that each time that I click on the link Failed to execute the [velocity] macro with my personal user (or even with another user, for example Admin), no log entry is recorded in the catalina.out file. As I explained you yesterday, the logtrace is shown always imcomplete/cut; I know perfectly that there are 109 more lines which are not in this trace, but I do not know where are all the lines being written.
Do yo have any idea about what is the log file where all this info is recorded? I grant you that in catalina.out there is no trace of them. Moreover, I tried to attach you an screenshot of the stacktrace, but this forum does not allow me to upload it. Any suggestion about the root cause, any proposal?
The last line of the trace is the following one:

Caused by: java.lang.NullPointerException

Regards,

I.R.G

They should be displayed on screen. I see no reason why they’d be cut. We certainly don’t trim them in XWiki.

Now let’s look at the error in more detail. It says:

This corresponds to the following line in the script:

So what could be null?

IMO the only thing that could be null is that you don’t have the wiki script service in your wiki (i.e. you’re missing some core extension).

It’s easy to check. Can you create a new page and put the following in it and then save and tell us what you get:

{{velocity}}
$services.wiki
$services.wiki.user
{{/velocity}}

Actually what the error say if that there is a NullPointerException inside isMember method. Hard to tell where exactly without the following Caused by but I would bet on one of the parameters.

Good afternoon, Vincent,

Thank you very much again for your attention and support. I have understootd a little bit the possible root cause that you have explained me. Just a couple of questions:

1.- When you say: “IMO the only thing that could be null is that you don’t have the wiki script service in your wiki”, does it mean that a file containing an script has been moved from a location in our xwiki server (a directory/path) to another location?

2.- The new page you “invite” me to create pasting the 4 code lines above, where must I create it? That’s to say, do I have to add a new page with that code, from the ADD menu?

Kind regards,

Good mornint, Tmortagne:

Thanks for your response. What I see is that this issue is very difficult to solve, and it is closely related to development themes. I have another alternative to access the list of wikis in our Xwiki.
You can close this case.

Kind regards,

Ignacio