icfnext / aem-groovy-extension

OSGi bundle containing Groovy builders and metaclasses for Adobe Experience Manager.
http://icfnext.github.io/aem-groovy-extension/groovydocs/index.html
Other
4 stars 10 forks source link

NoClassDef Found Error when running a script with recurse #7

Open ehtulhaq opened 4 years ago

ehtulhaq commented 4 years ago

I'm writing a script that uses recurse on a page. However at times i encounter the following error. Not sure whats going wrong.

aem-groovy-extension version 4.0.0

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: com/icfolson/aem/groovy/extension/services/impl/DefaultMetaClassExtensionProvider$__clinit__closure6$_closure34$_closure38
   at com.icfolson.aem.groovy.extension.services.impl.DefaultMetaClassExtensionProvider$__clinit__closure6$_closure34.doCall(DefaultMetaClassExtensionProvider.groovy:282)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
   at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:84)
   at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
   at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
   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:128)
   at scripts.testScript.Script1$_run_closure2.doCall(Script1.groovy:254)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
ericvangeem commented 4 years ago

Hi @ehtulhaq, what version of AEM as well as AEM Groovy Console are you using? I suspect you may be using an incompatible version of the AEM Groovy Console with your AEM instance. If using AEM 6.3 or later, please try installing the latest version of the AEM Groovy Console as found here: https://github.com/icfnext/aem-groovy-console/releases.

If you are still facing issues after this, please share the script you are trying to execute which results in this error.

ehtulhaq commented 4 years ago

@ericvangeem I'm on AEM 6.3 and the version of groovy console is 11.3.0 and groovy extension plugin 4.x.x. The console works fine as almost all the scripts I run execute without any problem. This problem happens intermittently after a package install and especially after the 'groovy extensions' package restarts. Example code that throws error -

resource.adaptTo(Page).recurse { page ->
....
}
ericvangeem commented 4 years ago

@ehtulhaq I recommend first uninstalling both the groovy extension bundle and groovy console bundle, then try installing groovy console v12.1.0 to see if that helps.

If that fixes your issue, then I would lastly recommend installing the latest version of groovy console. Just note that as of v13.0.0, the path to the console changes from /etc/groovyconsole.html to /var/groovyconsole.html, and you will have to manually add the 'administrator' group to the list of Allowed Groups in the Groovy Console Configuration Service in /system/console/configMgr