icfnext / aem-groovy-console

The AEM Groovy Console provides an interface for running Groovy scripts in the AEM container. Scripts can be created to manipulate content in the JCR, call OSGi services, or execute arbitrary code using the CQ, Sling, or JCR APIs.
Other
159 stars 94 forks source link

java.lang.NullPointerException: Cannot invoke method recurse() on null object #70

Closed chicago60614 closed 6 years ago

chicago60614 commented 6 years ago

I just installed the Groovy 11.0 package to my local instance of AEM 6.3. Most of the sample scripts don't work. Scripts that worked on my existing CQ 5.5 / Groovy 3 instances don't work in AEM6.3/Groovy11.0.

getPage should work but does not.

Any suggestions?

getPage("/content").recurse { page -> }

java.lang.NullPointerException: Cannot invoke method recurse() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)

2017-12-17_14-12-17

toniedzwiedz commented 6 years ago

@chicago60614 I haven't used these versions yet but I think the Groovy Console uses PageManager internally when you call getPage. If it's returning null, it's probably due to the structure of your content. I'd start by checking if the /content node exists and if it is an actual Page. What's its jcr:primaryType?

markdaugherty commented 6 years ago

/content is a sling:OrderedFolder node, not a page, so that is why the getPage method is returning null. You can use the getNode method, however, and call recurse() on the node instead.

I am in the process of updating the sample scripts - most of them depended on Geometrixx.

markdaugherty commented 6 years ago

See release 11.3.0 with updated sample scripts.