Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-16117

Make it possible to create new methods via the wiki component API

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • None
    • 11.0.3
    • Component
    • None
    • Unknown

    Description

      Use case

      It would be handy to create script services directly using the wiki component API. However, since the ScriptService interface has no method, and since the current wiki component API won't allow to create methods not declared in the component interface(s) (see steps below), it's not possible.

      Steps to reproduce the fact that wiki components methods cannot be created dynamically

      • Create a wiki component as described on the wiki component API page
      • Add an XWiki.ComponentInterfaceClass with interface name "org.xwiki.script.service.ScriptService"
      • Add an XWiki.ComponentMethodClass with name "helloWorld"
      • Give the component the hint "helloWorldComponent"
      • Save this component and create a wiki page calling the service method "helloWorld": services.helloWorldComponent.helloWorld()

      Expected result

      The expected result is that the "helloWorld" method gets executed and returns its output.

      Actual result

      The service method call returns the error below.

      Caused by: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy535.helloWorld() is applicable for argument types: () values: []
      	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:162)
      	at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.eval(AbstractJSR223ScriptMacro.java:351)
      	at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluateBlock(AbstractJSR223ScriptMacro.java:249)
      	at org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluateBlock(AbstractJSR223ScriptMacro.java:197)
      	... 156 more
      Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy535.helloWorld() is applicable for argument types: () values: []
      	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:324)
      	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:159)
      	... 159 more
      Caused by: groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy535.helloWorld() is applicable for argument types: () values: []
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:72)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:48)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
      	at Script382.run(Script382.groovy:2)
      	at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321)
      	... 160 more
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            slauriere slauriere
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: