TranslationException: Error getting Cloud Config credentials
My custom bootstrap connector (forked from this) produces this error running on AEM Cloud:
com.adobe.granite.translation.connector.bootstrap.core.impl.BootstrapTranslationServiceFactoryImpl Error while resolving config resource
com.adobe.granite.translation.api.TranslationException: Error getting Cloud Config credentials
The configuration is there in conf/global and interestingly it works in one environment but not in an other.
The error message refers to this function:
public BootstrapTranslationCloudConfigImpl(Resource translationConfigResource) throws TranslationException {
log.trace("BootstrapTranslationCloudConfigImpl.");
Resource configContent;
if (JcrConstants.JCR_CONTENT.equals(translationConfigResource.getName())) {
configContent = translationConfigResource;
} else {
configContent = translationConfigResource.getChild(JcrConstants.JCR_CONTENT);
}
if (configContent != null) {
ValueMap properties = configContent.adaptTo(ValueMap.class);
this.dummyServerUrl = properties.get(PROPERTY_DUMMY_SERVER_URL, "");
this.dummyConfigId = properties.get(PROPERTY_DUMMY_CONFIG_ID, "");
this.previewPath = properties.get(PROPERTY_PREVIEW_PATH, "");
if (log.isTraceEnabled()) {
log.trace("Created Bootstrap Cloud Config with the following:");
log.trace("dummyServerUrl: {}", dummyServerUrl);
log.trace("dummyConfigId: {}", dummyConfigId);
log.trace("previewPath: {}", previewPath);
}
} else {
throw new TranslationException("Error getting Cloud Config credentials",
TranslationException.ErrorCode.MISSING_CREDENTIALS);
}
}
called by this:
@Override
public TranslationService createTranslationService(TranslationMethod translationMethod, String cloudConfigPath)
throws TranslationException {
log.trace("BootstrapTranslationServiceFactoryImpl.createTranslationService");
BootstrapTranslationCloudConfig bootstrapCloudConfg = null;
String dummyConfigId = "";
String dummyServerUrl = "";
String previewPath = "";
try {
Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, "bootstrap-service");
ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(param);
Resource res = resourceResolver.getResource(cloudConfigPath);
bootstrapCloudConfg = (BootstrapTranslationCloudConfig) cloudConfigUtil
.getCloudConfigObjectFromPath(res, BootstrapTranslationCloudConfig.class, cloudConfigPath);
if (res != null) {
bootstrapCloudConfg = new BootstrapTranslationCloudConfigImpl(res);
}
} catch (Exception ex) {
log.error("Error while resolving config resource", ex);
}
if (bootstrapCloudConfg != null) {
dummyConfigId = bootstrapCloudConfg.getDummyConfigId();
dummyServerUrl = bootstrapCloudConfg.getDummyServerUrl();
previewPath = bootstrapCloudConfg.getPreviewPath();
}
Map<String, String> availableLanguageMap = new HashMap<String, String>();
Map<String, String> availableCategoryMap = new HashMap<String, String>();
return new BootstrapTranslationServiceImpl(availableLanguageMap, availableCategoryMap, factoryName,
isPreviewEnabled, isPseudoLocalizationDisabled, exportFormat, dummyConfigId, dummyServerUrl, previewPath
translationConfig, bootstrapTmsService);
}
Why it fails to load the configuration?