valtech / aem-easy-content-upgrade

AEM Easy Content Upgrade simplifies content migrations in AEM projects
Other
61 stars 26 forks source link

Script failure during deployment on AEM as a cloud when script uses groovyconsole or aecu methods #184

Closed michal-tobiasz-wttech closed 2 years ago

michal-tobiasz-wttech commented 2 years ago

I did the deployment in Cloud Manager for the AEM as Cloud. After the run, I checked the script's execution history and I saw failure for a script that uses groovy console methods or aecu methods. Looking into history the same script after a few seconds was again executed without any issue.

Is it looks like the scripts are executed too early?

groovy.lang.MissingMethodException: No signature of method: Script1.getPage() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [/content/test/us/en//groovy-testing]
Possible solutions: getClass(), getAt(java.lang.String)
royteeuwen commented 2 years ago

I am facing the same problem:

Path: [/apps/aecu-scripts/testMigrationTrigger2.always.groovy](/apps/aecu-scripts/testMigrationTrigger2.always.groovy)

groovy.lang.MissingPropertyException: No such property: aecu for class: Script1
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
    at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:310)
    at Script1.run(Script1.groovy:2)
    at Script1$run.call(Unknown Source)
    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 com.icfolson.aem.groovy.console.impl.DefaultGroovyConsoleService$_runScript_closure2.doCall(DefaultGroovyConsoleService.groovy:88)
    at com.icfolson.aem.groovy.console.impl.DefaultGroovyConsoleService$_runScript_closure2.doCall(DefaultGroovyConsoleService.groovy)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:41)
    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 com.icfolson.aem.groovy.console.impl.DefaultGroovyConsoleService$__clinit__closure6.doCall(DefaultGroovyConsoleService.groovy:50)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
    at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:947)
    at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:930)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:181)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeClosure(ScriptBytecodeAdapter.java:587)
    at com.icfolson.aem.groovy.console.impl.DefaultGroovyConsoleService.runScript(DefaultGroovyConsoleService.groovy:87)
    at de.valtech.aecu.core.service.AecuServiceImpl.executeScript(AecuServiceImpl.java:209)
    at de.valtech.aecu.core.service.AecuServiceImpl.execute(AecuServiceImpl.java:183)
    at de.valtech.aecu.core.service.AecuServiceImpl.executeWithInstallHookHistory(AecuServiceImpl.java:364)
    at de.valtech.aecu.core.service.AecuCloudStartupService.startAecuMigration(AecuCloudStartupService.java:73)
    at de.valtech.aecu.core.service.AecuCloudStartupService.activate(AecuCloudStartupService.java:63)
gruberrolandvaltech commented 2 years ago

@michal-tobiasz-wttech can you provide your Groovy script?

@royteeuwen does this happen on each deploy? If yes, please provide your Groovy script. We have implemented some code to avoid the MissingPropertyException but maybe it needs a bit more.

royteeuwen commented 2 years ago

@gruberrolandvaltech I just checked again, and it seems to only sometimes (see screenshot).

The script is very easy: testMigrationTrigger2.always.groovy

//should run every time and create a test object
aecu.contentUpgradeBuilder()
        .forResources((String[])["/var/my-site/migration-tests"])
        .doCreateResource(new Date().format("yyyyMMddHHmmss"), "nt:unstructured")
        .run()

Screenshot 2022-05-16 at 09 13 45

michal-tobiasz-wttech commented 2 years ago

In my case is:

getPage('/content/wknd')

aecu.contentUpgradeBuilder()
        .forChildResourcesOf('/content/wknd')
        .printPath()
        .run()
gruberrolandvaltech commented 2 years ago

Thanks to both of you for the extra information. Looks like in one case Groovy Console's internal binding service is not yet up. In the other case it seems the AECU binding service is up but not yet registered in Groovy Console. We will check how this can be handled.

gruberrolandvaltech commented 2 years ago

Should be fixed with https://github.com/valtech/aem-easy-content-upgrade/pull/186