• mantat lam
    mantat lam, 2011/03/03 20:54

    Hi Sergiu ,

       I got the error!  Any thoughts on that?

    org.xwiki.rendering.macro.MacroExecutionException: Failed to evaluate Script Macro for content [if (!xwiki.hasAccessLevel("admin")) {
      println("You are not allowed to access this document.")
      return;
    }

    def sorter = new org.apache.velocity.tools.generic.SortTool();
    def path = org.apache.commons.lang.StringUtils.defaultString(request.path, "/");
    path = new File(path);
    if (!path.exists()) {
      path = new File("/");
    }
    if (path.isDirectory()) {
      println ("(% style='width: 100%' %)");
      println ("|=File|=Modified|=Size");
      if (path.getCanonicalPath() != "/") {
        println ("|[[..>>?path=" + path.getParentFile().getCanonicalPath() + "]]||");
      }
      for (f in sorter.sort(path.listFiles(), ["directory:desc", "name"])) {
        print("|[[" + f.getName()+ ">>?path=" + f.getCanonicalPath() + (f.isDirectory() ? "" : "&xpage=plain") + "]]|" + xwiki.formatDate(new Date(f.lastModified()), "yyyy/MM/dd HH:mm:ss") + "|");
        if (f.isFile()) {
          print(f.length());
        }
        println();
      }
    } else {
      try {
        org.apache.commons.io.IOUtils.copy(org.apache.commons.io.FileUtils.openInputStream(path), response.getOutputStream());
    response.getOutputStream().close();
      } catch (Exception ex) {
        println ("Access denied to this file");
      }
    }]
    at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluateBlock(AbstractJSR223ScriptMacro.java:174)
    at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluateBlock(AbstractJSR223ScriptMacro.java:52)
    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:7444)
    at com.xpn.xwiki.doc.XWikiDocument.performSyntaxConversion(XWikiDocument.java:7393)
    at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:832)
    at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:781)
    at com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:875)
    at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:546)
    at sun.reflect.GeneratedMethodAccessor344.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: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:1886)
    at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1824)
    at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:837)
    at sun.reflect.GeneratedMethodAccessor128.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: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.parseTemplate(XWiki.java:1935)
    at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:1856)
    at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:154)
    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: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.web.ActionFilter.doFilter(ActionFilter.java:129)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.xpn.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:152)
    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 org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:218)
    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: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:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: javax.script.ScriptException: javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getCanonicalPath() on null object
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)
    at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.eval(AbstractJSR223ScriptMacro.java:277)
    at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluateBlock(AbstractJSR223ScriptMacro.java:209)
    at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluateBlock(AbstractJSR223ScriptMacro.java:169)
    ... 92 more
    Caused by: javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getCanonicalPath() on null object
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:318)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111)
    ... 95 more
    Caused by: java.lang.NullPointerException: Cannot invoke method getCanonicalPath() on null object
    at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
    at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at Script1.run(Script1.groovy:16)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:315)
    ... 96 more

    thanks

    • Sergiu Dumitriu
      Sergiu Dumitriu, 2011/03/04 00:11

      Do you get the error every time, starting with the first time you open the page, or only for a specific path?

      Are you running XWiki on a Windows server?

      • mantat lam
        mantat lam, 2011/03/04 00:25

        I followed your instruction to import the XAR file and add that page in one of my test space.  The errors show up everytime.  And I am running that in windows tomcat server.

        • Sergiu Dumitriu
          Sergiu Dumitriu, 2011/03/04 00:58

          Try using the new version 1.1.

          • mantat lam
            mantat lam, 2011/03/04 21:00

            Work as expected.  Thanks alot.
            2 comments:
            The table width is too long, the scroll bar at the bottom show up all the time.
            click on the empty drive won't refresh (I dont have any disk in DVD rom, when click on D:, still show content in Cemoticon_smile

            Again, thanks for the quick response. It is a very useful extension.

  • Deven Phillips
    Deven Phillips, 2014/05/01 16:47

    I just found what appears to be a bug... When trying to browse into a directory which is named "Matter+Form", I get the directory listing for "/" (root)!! Oh noes!!! I'm using Chrome browser on Windows 7 and I am running XWiki 5.4.4 on Ubuntu. Any help would be appreciated! I just checked and if I replace the "+" in the URL with %2B it works fine.

  • Alex H
    Alex H, 2016/08/16 13:14

    Is there a solution so that on Windows it will get a forward slash and not a backslash  
    Currently get: Filesystem?path=C:\#
    I want: Filesystem?path=C:/#

Get Connected