AIF - Object reference not set to an instance of an object
When trying to process any outbound document on the AIF message queue, the document fails when processed through batch jobs with the following error: Object reference not set to an instance of an object.
If it is processed in X++ with the little piece of code below:
static void job1(Args _args)
{
AifQueueManager document;
select firstOnly document where document.MessageId == GUID;
// This static method is declared as private and this trick is to avoid changing the access specifier on the class
new SysDictClass(classNum(AifOutboundProcessingService)).callStatic('processAsUser', [document.MessageId]));
}
It will give a more descriptive error message and even a stack trace.
Map object not initialized.
Stack trace
(S)\Classes\AxdUtil\expandQueryForSfkReplacement - line 17
(S)\Classes\AxdUtil\expandSurrogateForeignKeys - line 16
(S)\Classes\AxdBaseRead\copyQueryLocally - line 16
(S)\Classes\AxdBaseRead\readDocumentList - line 29
(S)\Classes\AxdBase\readList - line 89
(S)\Classes\AifDocumentService\readList - line 50
(S)\Classes\POChangeService\read - line 14
(S)\Classes\DictClass\callObject
(S)\Classes\AifDispatcher\callServiceMethod - line 65
(S)\Classes\AifDispatcher\dispatchOperation - line 23
(S)\Classes\AifRequestProcessor\processOutbound - line 102
(S)\Classes\AifOutboundProcessingService\processRequest - line 28
(S)\Classes\AifOutboundProcessingService\processAsyncRequest - line 72
(S)\Classes\AifOutboundProcessingService\processAsUser - line 28
(C)\Classes\DictClass\callStatic
(C)\Jobs\Job1 - line 17
The reason for it to fail, is that the AIF framework can't find a map containing meta data information about the AxD class and the involved query.
The AIF framework figures out that the map doesn't exist at runtime and creates it correctly during process time. But after creating it, it loses the object reference to the newly created map.
The way to solve this is to open the AIF Global Settings from and enable the <Enable runtime caching>. See screenshot below. If this is not set, all outbound AIF documents will fail to be processed.
Comments
- Anonymous
April 28, 2013
i have apply above solution on customize table using AIfGenericDocumentService but no effect and facing object reference not set to an instance of an object kindly suggest any solution