Where is wiki being set in Groovy? It's not being set in the method you show.
This looks like a typo to me. Shouldn't you be using xwiki instead?
It looks to me that you haven't set a class variable for xwiki (or wiki if
thats the true object variable being used). Without it being set, it will
default to null.
class groovyClass {
def xwiki;
void setXWiki(xwiki) {
this.xwiki = xwiki;
}
// now you can use xwiki in other methods of the class.
...
}
-Dean
ArielWang wrote:
I am upgrading XWIKI from 1.1 to 1.8 in my sites.
And I use Groovy for the user rights module.
When I update the user rights, errors occurs:
Error number 4001 in 4: Error while parsing velocity page
MyNetcipia.PlaceRightsConfirmation
Wrapped Exception: Failed to evaluate content with id Place Rights
Confirmation
com.xpn.xwiki.XWikiException: Error number 4001 in 4: Error while parsing
velocity page MyNetcipia.PlaceRightsConfirmation
Wrapped Exception: Failed to evaluate content with id Place Rights
Confirmation
at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:114)
at
com.xpn.xwiki.render.XWikiVelocityRenderer.render(XWikiVelocityRenderer.java:85)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:272)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:202)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:170)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderDocument(DefaultXWikiRenderingEngine.java:159)
at
com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:525)
at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:450)
at sun.reflect.GeneratedMethodAccessor261.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.invoke(UberspectImpl.java:295)
at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:107)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:108)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1662)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1612)
at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:696)
at sun.reflect.GeneratedMethodAccessor96.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.invoke(UberspectImpl.java:295)
at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:194)
at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:88)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:107)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:108)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1662)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1612)
at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:124)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:242)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:122)
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:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
com.xpn.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:145)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:111)
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:68)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:295)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112)
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:175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
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:263)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Thread.java:619)
Wrapped Exception:
org.apache.velocity.exception.MethodInvocationException: Invocation of
method 'updateRights' in class PlaceManager threw exception
java.lang.NullPointerException: Cannot invoke method getDocument() on null
object @ MyNetcipia.PlaceRightsConfirmation11,15
at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:286)
at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at
org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTReference.java:396)
at
org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExpression.java:64)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:86)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:107)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:108)
at
com.xpn.xwiki.render.XWikiVelocityRenderer.render(XWikiVelocityRenderer.java:85)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:272)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:202)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderText(DefaultXWikiRenderingEngine.java:170)
at
com.xpn.xwiki.render.DefaultXWikiRenderingEngine.renderDocument(DefaultXWikiRenderingEngine.java:159)
at
com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:525)
at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:450)
at sun.reflect.GeneratedMethodAccessor261.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.invoke(UberspectImpl.java:295)
at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
at
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:107)
at org.apache.velocity.runtime.parser.node.SimpleNode.r
ender(SimpleNode.java:318) at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
at org.xwiki.vel
ocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143) at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWik
iVelocityRenderer.java:108) at
com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1662) at
com.xpn.xwiki.XWiki.parseTemplate(XWiki.jav
a:1612) at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:696) at
sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Met
hod.java:597) at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295)
at org.apach
e.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245) at
org.apache.velocity.runtime.parser.node.ASTReference.exe
cute(ASTReference.java:203) at
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
at org.apache.
velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318) at
org.apache.velocity.runtime.directive.VelocimacroProxy.
render(VelocimacroProxy.java:194) at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170)
at org
.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.re
nder(ASTIfStatement.java:88) at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
at org.apache.velocity
.runtime.parser.node.SimpleNode.render(SimpleNode.java:318) at
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(AST
IfStatement.java:107) at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
at org.xwiki.velocity.De
faultVelocityEngine.evaluate(DefaultVelocityEngine.java:178) at
org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocit
yEngine.java:143) at
com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:108)
at com.xpn.xwiki.XWiki.
parseTemplate(XWiki.java:1662) at
com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1612) at
com.xpn.xwiki.web.Utils.parseTemplate(Ut
ils.java:124) at
com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:242) at
com.xpn.xwiki.web.XWikiAction.execute(XWikiActio
n.java:122) at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.ac
tion.RequestProcessor.process(RequestProcessor.java:236) at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:11
96) at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at
javax.servlet.http.HttpServlet.service(HttpServle
t.java:690) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at
org.apache.catalina.core.ApplicationFilterChain.i
(ApplicationFilterChain.java:290) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
a
t
com.xpn.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:145)
at org.apache.catalina.core.Applicati
onFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(Appl
icationFilterChain.java:206) at
com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:111) at
org.apache.catalina.core.Appli
cationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(
.java:206) at
com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:68)
at org.apache.catalina.core.Applicatio
nFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli
cationFilterChain.java:206) at
com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:295)
at org
.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.Appli
cationFilterChain.doFilter(ApplicationFilterChain.java:206) at
com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacte
rEncodingFilter.java:112) 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.Standa
rdWrapperValve.invoke(StandardWrapperValve.java:233) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:175) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.Error
ReportValve.invoke(ErrorReportValve.java:102) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10
9) at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.jk.server.JkCoyoteHandler.invoke
(JkCoyoteHandler.java:190) at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283) at
org.apache.jk.common.Channe
lSocket.invoke(ChannelSocket.java:767) at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.ap
ache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$Control
Runnable.run(ThreadPool.java:690) at
java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException: Cannot invoke method
getDocument() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at
org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:748)
at
org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:725)
at
org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:17)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:129)
at PlaceManager.updateRights(script1247022056918.groovy:622)
at PlaceManager$updateRights.callCurrent(Unknown Source)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:47)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at PlaceManager.updateRights(script1247022056918.groovy:712)
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.invoke(UberspectImpl.java:295)
at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
… 95 more
I see one sentence:
Wrapped Exception:
org.apache.velocity.exception.MethodInvocationException: Invocation of
method 'updateRights' in class PlaceManager threw exception
java.lang.NullPointerException: Cannot invoke method getDocument() on null
object @ MyNetcipia.PlaceRightsConfirmation11,15
I find there is null in Groovy:(bold is null value)
public boolean updateRights(String space) {
Document doc = new
Document(wiki.xWiki.getDocument(getRightsPage(space),context.context),context.context)
if ((doc!=null)&&(!doc.isNew())) {
for (obj in doc.getObjects("XWiki.XWikiGlobalRights")) {
doc.removeObject(obj)
}
doc.saveWithProgrammingRights()
}
boolean update = false;
if (doc!=null) {
update |= updateRights(space, "view",
doc.newObject("XWiki.XWikiGlobalRights"))
update |= updateRights(space, "edit",
doc.newObject("XWiki.XWikiGlobalRights"))
update |= updateRights(space, "comment",
doc.newObject("XWiki.XWikiGlobalRights"))
if (space=="") {
// Make sur the admin rights is set
update |= addAdminRights(doc.newObject("XWiki.XWikiGlobalRights"))
}
} else
return false;
if (update)
doc.saveWithProgrammingRights()
return true;
}
But I cannot find which causes the null value and how to avoid this.
--
View this message in context:
http://n2.nabble.com/Groovy-Errors-tp3254453p3255062.html
Sent from the XWiki- Users mailing list archive at
Nabble.com.