muenzpraeger / salesforce-einstein-platform-apex

Apache License 2.0
88 stars 51 forks source link

PEM not found in Future Method or Queueable Apex #86

Closed mgcdanny closed 5 years ago

mgcdanny commented 6 years ago

For whatever reason the PEM file is not found when I run my code as a Future or Queueable Apex class. However, the file IS found when I run it as "anonymous execution"

Sandbox

Apex script unhandled exception by user/organization: 00539000005k15c/00D4C0000008m4E
Source organization: 00D390000003wR6 (null)
Failed to invoke future method 'public static void detectURL3(String)' on class 'EinsteinVisionHelper' for job id '7074C00000Twcnn'

caused by: Einstein_ConfigurationException: Could not retrieve the Einstein Platform certificate file: einstein_platform_playground

Class.Einstein_PredictionService.getAccessToken: line 965, column 1
Class.Einstein_PredictionService.<init>: line 34, column 1
Class.EinsteinVisionHelper.detectURL3: line 21, column 1
Caused by
Class.Einstein_PredictionService.getAccessToken: line 963, column 1
Class.Einstein_PredictionService.<init>: line 34, column 1
Class.EinsteinVisionHelper.detectURL3: line 21, column 1
muenzpraeger commented 6 years ago

Pls make sure that the visibility settings for the pem are correctly set.

mgcdanny commented 6 years ago

Visibility is set to "All Users" , is that "correctly set"?

image

mgcdanny commented 6 years ago

FWIW this is where the problem is, I was able to comment it out and just hardcode the PEM file for now:

                    ContentVersion base64Content;
                    // Try to retrieve certificate
                    /* 

                    try {
                        base64Content = [SELECT Title, VersionData FROM ContentVersion where Title=: tokenFileName AND IsLatest=true order by CreatedDate DESC LIMIT 1];
                    } catch (QueryException e) {
                        throw new Einstein_ConfigurationException('Could not retrieve the Einstein Platform certificate file: einstein_platform_playground', e);
                    }
muenzpraeger commented 5 years ago

This project gets archived, as it's functionality is now available on the AppExchange.