valtech / aem-easy-content-upgrade

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

AEMaaCS doesn't start AECU Migration, due to wrong check in AecuCloudStartupService -> servicesAreOk #210

Closed rubnig closed 1 year ago

rubnig commented 1 year ago

It looks like the check in the AecuCloudStartupService -> servicesAreOk is not 100% working.

The following piece of code tries to load the be.orbinson.aem.groovy.console.extension.impl.DefaultExtensionService which is provided by the aem-groovy-console-bundle.

private static final String DEFAULT_EXTENSION_SERVICE =
            "be.orbinson.aem.groovy.console.extension.impl.DefaultExtensionService";

// ...            

Bundle bundle = FrameworkUtil.getBundle(BindingExtensionProvider.class);
ComponentDescriptionDTO componentDescription =
     serviceComponentRuntime.getComponentDescriptionDTO(bundle, DEFAULT_EXTENSION_SERVICE);
if ((componentDescription == null) || !serviceComponentRuntime.isComponentEnabled(componentDescription)) {
    return false;
}

But the line Bundle bundle = FrameworkUtil.getBundle(BindingExtensionProvider.class); can return a different bundle: aem-groovy-console-api instead of aem-groovy-console-bundle, which doesn't contain the be.orbinson.aem.groovy.console.extension.impl.DefaultExtensionService implementation class.

Which could result in not executing the AECU migration scripts on AEMaaCS:

15.03.2023 05:27:08.628 [cm-<>-aem-author-5557b7b64-4tcsd] *ERROR* [Thread-106] de.valtech.aecu.startuphook.AecuCloudStartupService Groovy extension services seem to be not bound

To avoid this problem, we could just fetch the right bundle by its symbolic name aem-groovy-console-bundle (it is a required header for OSGi bundles).

Bundle bundle = Arrays.stream(bundleContext.getBundles())
      .filter(b -> GROOVY_CONSOLE_BUNDLE_SYMBOLIC_NAME.equals(b.getSymbolicName()))
      .findFirst().orElse(null);

What do you guys think?

rubnig commented 1 year ago

Sample fix: https://github.com/valtech/aem-easy-content-upgrade/pull/211

rubnig commented 1 year ago

Another way to fix this, would be to use a different service & component description dto, from a service that is only available within the aem-groovy-console-bundle