I have just carefully upgraded a wiki from 2.6 to 3.1
At first glance It seemed to have gone fine, but I noticed velocity errors on the
new-style Admin page (XWiki.XWikiPreferences):
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
...
Caused by: org.apache.velocity.runtime.parser.TemplateParseException: Encountered
"\'checkbox\'" at xwiki:XWiki.AdminSheet[line 231, column 26]
Was expecting one of:
"," ...
")" ...
<WHITESPACE> ...
...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(full error message copied below)
The result is that none of the administration pages displays properly.
Has anyone an idea of what might be causing this problem?
Thanks for your help,
Tim
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Failed to execute the [velocity] macro
org.xwiki.rendering.macro.MacroExecutionException: Failed to evaluate Velocity Macro for
content [## Constants:
#set($redirectParameter = 'xredirect')
#set($nameOfThisDocument = 'XWiki.ConfigurableClass')
#*
* If this document is saved with programming access or is includeForm'd into a
document with programming, we have to
* drop programming rights in order for it to run safely because it evaluates potentially
untrustworthy code.
*###
#macro(sandboxDocument)
#if($xcontext.hasProgrammingRights())
$xcontext.dropPermissions()##
#end
#end
#*
* Any documents which are on the provided list ($documentNames) which are locked by the
current user will be unlocked.
* If this macro has programming rights, then they are unlocked programmatically,
otherwise a javascript tag is
* generated with ajax calls to cancel for all of the documents. If there are documents on
this list which are not
* locked by the current user, then they are ignored.
*
* @param $documentNames - List<String> - fullNames of documents which should be
unlocked if they are locked by the
* current user.
*###
#macro(unlockDocuments $documentNames)
#if($documentNames.size() > 0)
#set($sql = "doc.fullName=")
#foreach($documentName in $documentNames)
#set($sql = "${sql}'$documentName' or doc.fullName=")
#end
## Trim the dangling ' or doc.fullName=?'
#set($sql = $sql.substring(0, $sql.lastIndexOf(' or doc.fullName=')))
#set($sql = ", XWikiLock lock where lock.docId=doc.id and
lock.userName='$xcontext.getUser()' and (${sql})")
#set($namesOfdocumentsToUnlock = $xwiki.searchDocuments($sql))
## Use ajax and hope the user runs javascript.
{{html}}
<script type="text/javascript">
document.observe("dom:loaded", function() {
#foreach($nameOflockedDocument in $namesOfdocumentsToUnlock)
new Ajax.Request("$xwiki.getURL($nameOflockedDocument, 'cancel',
'ajax=1')");
#end
});
</script>
{{/html}}
#end## If output list size > 0
#end
#*
* Try to determine whether a document was edited by a user who has edit right on this
page. This is tricky because
* documents are imported with the name XWiki.XWikiGuest who has no access to anything
after import.
*
* @param theDoc - Document who's editor should be checked for edit access on this
document.
*###
#macro(checkDocumentSavedByAuthorizedUser, $docToCheck, $currentDoc, $hasAccess)
## The system is started and the only user is XWikiGuest who has admin right but gives
it up when he imports the default
## documents, we are checking to see if this looks like the guest imported the document
with the first import.
#if($docToCheck.getWiki() == $xcontext.getMainWikiName()
&& $docToCheck.getVersion() == '1.1'
&& $docToCheck.getCreator() != $docToCheck.getContentAuthor()
&& $docToCheck.getContentAuthor() == 'XWiki.XWikiGuest')
##
#set($userToCheck = $docToCheck.getCreator())
#else
#set($userToCheck = $docToCheck.getAuthor())
#end
#set ($hasAccess = $util.null)
#setVariable ("$hasAccess" $xwiki.hasAccessLevel('edit', $userToCheck,
$currentDoc))
#end
#*
* Find names of documents which contain objects of the class
'XWiki.ConfigurableClass'
*
* @param $section - String - Look for apps which specify that they should be configured
in this section,
* if null or "" then returns them for all sections.
*
* @param $globaladmin - boolean - If true then we will look for applications which should
be configured globally.
*
* @param $space - String - If not looking for apps which are configured globally, then
this is the space where we
* will look for apps in. If null or "" or if
$globaladmin is true, then all spaces will be
* searched.
*
* @param $outputList - List - The returns from this macro will be put in this list,
passing the list as a parameter
* a safety measure because macros can't return values.
*###
#macro(findNamesOfAppsToConfigure, $section, $globaladmin, $space, $outputList)
## Use a parameterized sql query to prevent injection.
#set($params = [])
#if($section && $section != '')
#set($discard = $params.add("$section"))
#set($sqlA = ' StringProperty as section,')
#set($sqlB = " and section.id=obj.id and section.name='displayInSection'
and section.value=?")
#else
## Make sure they are "" in case they were set prior to calling the macro.
#set($sqlA = '')
#set($sqlB = '')
#end
## Set up query based on value of $globaladmin
#if($globaladmin == true)
#set($sqlC = '1')
#else
#if($space && $space != '')
#set($sqlC = '0 and doc.space = ?')
#set($discard = $params.add($space))
#else
#set($sqlC = '0')
#end
#end
#set($sql = ", BaseObject as obj,$sqlA IntegerProperty as global where "
+ "doc.fullName=obj.name and obj.className='" +
$nameOfThisDocument + "'$sqlB "
+ "and global.id=obj.id and global.name='configureGlobally' and
global.value=$sqlC "
+ "order by doc.creationDate")
##
## Run the search
#set($discard = $outputList.addAll($xwiki.searchDocuments($sql, 0, 0, $params)))
##
#end
#macro(findCustomSectionsToConfigure $adminMenu)
#set ($outputList = [])
#set ($global = ($editor == 'globaladmin'))
#findNamesOfAppsToConfigure('', $global, $currentSpace, $outputList)
#set ($sectionsByName = {})
#set ($categoriesByName = {})
#foreach ($category in $adminMenu)
#set ($discard = $categoriesByName.put($category.id, $category))
#foreach ($section in $category.children)
#set ($discard = $sectionsByName.put($section.id, $section))
#end
#end
##
#set ($query = "editor=$escapetool.url(${editor})")
#if ($editor != 'globaladmin')
#set ($query = $query + "&space=$escapetool.url(${currentSpace})")
#end
#foreach ($appName in $outputList)
##
## Get the configurable application
#set ($app = $xwiki.getDocument($appName))
##
## If getDocument returns null, then warn the user that they don't have view
access to that application.
#if (!$app)
! #set ($discard = $appsUserCannotView.add($appName))
#end
##
#foreach ($configurableObject in $app.getObjects($nameOfThisDocument))
#set ($displayInSection = $app.getValue('displayInSection',
$configurableObject))
##
## If there is no section for this configurable or if the section cannot be edited,
then check if the
## application can be edited by the current user, if so then we display the icon
from the current app and
## don't display any message to tell the user they can't edit that section.
#if ($sectionsByName.containsKey($displayInSection))
#set ($appSection = $sectionsByName.get($displayInSection))
#set ($appSection.configurable = true)
#set ($newSection = false)
#else
##
## If there is no section for this configurable, then we will have to add one.
#set ($appSection = {'id' : $displayInSection, 'name' :
$msg.get("admin.${displayInSection.toLowerCase()}"), 'url':
$xwiki.getURL($currentDoc, $adminAction,
"${query}&section=$escapetool.url(${displayInSection})"),
'configurable' : true})
#if ($app.getValue('configureGlobally', $configurableObject) != 1)
#set ($appSection.perSpace = true)
#end
#set ($key = "admin.${displayInSection.toLowerCase()}.description")
#if ($msg.get($key) != $key)
#set ($appSection.description = $msg.get($key))
#end
#set ($discard = $sectionsByName.put($displayInSection, $appSection))
#set ($discard =
$categoriesByName.get('applications').children.add($appSection))
#set ($newSection = true)
#end
##
## If an attachment by the filename iconAttachment exists and is an image
#set ($attachment =
$app.getAttachment("$!app.getValue('iconAttachment',
$configurableObject)"))
#if ($attachment && $attachment.isImage())
## Set the icon for this section as the attachment URL.
#set ($appSection.iconReference =
"${appName}(a)${attachment.getFilename()}")
#elseif(!$appSection.iconReference)
#set ($appSection.iconReference =
'XWiki.ConfigurableClass(a)DefaultAdminSectionIcon.png')
#end
##
## If the user doesn't have edit access to the application, we want to show a
message on the icon
#if (!$xcontext.hasAccessLevel('edit', $app.getFullName()) &&
$newSection)
#set ($appSection.readOnly = true)
#elseif ($xcontext.hasAccessLevel('edit', $app.getFullName()) &&
$appSection.readOnly)
#set ($appSection.readOnly = false)
#end
#end## Foreach configurable object in this app.
#end## Foreach application which is configurable.
#end
#*
* Show the heading for configuration for a given application.
*
* $appName (String) Name of the application to show configuration heading for.
*
* $headingAlreadyShowing (boolean) If true then we don't make another heading.
Otherwise it is set to true.
*###
#macro(showHeading, $appName, $headingAlreadyShowing)
#if(!$headingAlreadyShowing)
#set($headingAlreadyShowing = true)
= $msg.get("admin.customize") __[[$appName>>$appName]]__: =
#end
#end
#define($formHtml)
#if ($objClass.getPropertyNames().size() > 0)
<dl>
#foreach($propName in $objClass.getPropertyNames())
#if($propertiesToShow.size() > 0 &&
!$propertiesToShow.contains($propName))
## Silently skip over this property.
#else
#set($prettyName = "#evaluate($app.displayPrettyName($propName,
$obj))")
##
## Further processing of the field display HTML is needed.
## Step 1: Strip <pre> tags which $obj.display inserts, this won't
affect content because it's escaped.
#set($out = $obj.display($propName,
'edit').replaceAll('<[/]?+pre>', ''))
## Step 2: Select only content between first < and last > because
$obj.display inserts html macros.
## Careful not to remove html macros from the content because they are not
escaped!
#set ($out = $out.substring($out.indexOf('<'), $mathtool.add(1,
$out.lastIndexOf('>'))))
## Step 3: Prepend app name to all ID and FOR attributes to prevent id collision
with multiple apps on one page.
#set ($out = $out.replaceAll(
" id='$objClass.getName()_$obj.getNumber()_$propName", "
id='${escapedAppName}_$objClass.getName()_$obj.getNumber()_$propName").replaceAll(
" for='$objClass.getName()_$obj.getNumber()_$propName", "
for='${escapedAppName}_$objClass.getName()_$obj.getNumber()_$propName"))
## App Name is prepended to for= to make label work with id which is modified to
prevent collisions.
<dt><label
for="${escapedAppName}_$objClass.getName()_$obj.getNumber()_$propName">
#if ($out.indexOf('type=''checkbox''') != -1)
$out
#end
$escapetool.xml($prettyName)
</label>
#if($linkPrefix != '')
#set($linkScript = "$linkPrefix$propName")
<a href="$escapetool.xml("#evaluate($linkScript)")"
class="xHelp"
title="$msg.get('admin.documentation')">$msg.get('admin.documentation')</a>
#end
</dt>
#if ($out.indexOf('type=''checkbox''') == -1)
<dd>$out</dd>
#end
#end## If property is in propertiesToShow
#end## Foreach property in this class
</dl>
#end
#end## define $formHtml]
at
org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:125)
at
org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:44)
at
org.xwiki.rendering.macro.script.AbstractScriptMacro.evaluateBlock(AbstractScriptMacro.java:298)
at
org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:190)
at
org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:57)
at
org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transformOnce(MacroTransformation.java:184)
at
org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transform(MacroTransformation.java:129)
at
org.xwiki.rendering.internal.transformation.DefaultTransformationManager.performTransformations(DefaultTransformationManager.java:72)
at com.xpn.xwiki.doc.XWikiDocument.performSyntaxConversion(XWikiDocument.java:7409)
at com.xpn.xwiki.doc.XWikiDocument.performSyntaxConversion(XWikiDocument.java:7358)
at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:831)
at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:782)
at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:874)
at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
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:389)
at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:252)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:332)
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:336)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:106)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:196)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:161)
at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:116)
at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:1874)
at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:155)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:226)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:117)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:129)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
com.xpn.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:152)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:68)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:218)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:162)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.xwiki.velocity.XWikiVelocityException: Failed to evaluate content with id
[xwiki:XWiki.AdminSheet]
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:205)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:161)
at
org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:118)
... 72 more
Caused by: org.apache.velocity.runtime.parser.TemplateParseException: Encountered
"\'checkbox\'" at xwiki:XWiki.AdminSheet[line 231, column 26]
Was expecting one of:
"," ...
")" ...
<WHITESPACE> ...
at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:119)
at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1131)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:189)
... 74 more
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------