# Presence of a groovy script method depends on its argument

**URL:** <https://forum.xwiki.org/t/presence-of-a-groovy-script-method-depends-on-its-argument/6910>\
**Category:** Help / Discuss\
**Tags:** script, error, groovy\
**Created:** [May 22, 2020, 8:15am UTC](https://forum.xwiki.org/t/presence-of-a-groovy-script-method-depends-on-its-argument/6910 "2020-05-22T08:15:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![venclj](https://forum.xwiki.org/user_avatar/forum.xwiki.org/venclj/32/2662_2.png) [@venclj](https://forum.xwiki.org/u/venclj)\
**Post date:** [May 22, 2020, 8:15am UTC](https://forum.xwiki.org/t/presence-of-a-groovy-script-method-depends-on-its-argument/6910/1 "2020-05-22T08:15:41Z")

</div>

I am making a script traversing page tree structure. For some reasons I switched from python to groovy which is new to me. So this problem could be connected with xwiki script support as well as groovy.

I have a one argument method

```
  def includeDocWithChildren = {String documentRef ->
    def doc = xwiki.getDocument(documentRef)
    for(child in doc.getChildren()){
        includeDocWithChildren(child)
    }
}

```

Now I call it

```
includeDocWithChildren('Main.WebHome')

```

I get following error

```
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.includeDocWithChildren() is applicable for argument types: (String) values: [Main.WebHome]

```

When the string parameter is without dot (e.x. “Main-WebHome”), the method is found. Could you get me a hint what’s going on?

**Edit 2020-05-22:** Groovy script updated to contain the bad part. It would be nonsense without it.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [May 22, 2020, 10:11am UTC](https://forum.xwiki.org/t/presence-of-a-groovy-script-method-depends-on-its-argument/6910/2 "2020-05-22T10:11:44Z")

</div>

Hi, I think your problem is elsewhere from what you’re showing above. I’ve tried it [playgroung.xwiki.org](http://playgroung.xwiki.org) with:

```auto
{{groovy}}
 def includeDocWithChildren = {String documentRef ->
    def doc = xwiki.getDocument(documentRef)
}

includeDocWithChildren('Main.WebHome')
{{/groovy}}

```

And it works fine.

---

<div class="post-metadata">

**Author:** ![venclj](https://forum.xwiki.org/user_avatar/forum.xwiki.org/venclj/32/2662_2.png) [@venclj](https://forum.xwiki.org/u/venclj)\
**Post date:** [May 22, 2020, 11:18am UTC](https://forum.xwiki.org/t/presence-of-a-groovy-script-method-depends-on-its-argument/6910/3 "2020-05-22T11:18:36Z")

</div>

Thank you Vincent. I found the bug thanks to you. For need of this question I simplified the code too much. There was a recursive calling which caused the problem. I have learned that a variable needs to be defined before it is called.

The code …

```
{{groovy}}
def includeDocWithChildren = {String documentRef ->
    def doc = xwiki.getDocument(documentRef)
    for(child in doc.getChildren()) {
        includeDocWithChildren(child)
    }
}

includeDocWithChildren('Main.WebHome')
{{/groovy}}

```

… should start with

```
{{groovy}}
def includeDocWithChildren
includeDocWithChildren = {String documentRef ->
    ...
}
{{/groovy}}
```
