Expand my Community achievements bar.

SOLVED

AEM_FRM_001_006:resourceResolver is Null

Avatar

Employee

If the FormsService.renderPDFForm("crx:///content/xyz.xdp",...) is called with an xdp stored within the repository (using the crx://.... path), the FormsService retrieves that xdp from the repository using a ResourceResolver inherited from the context of the current request. This works fine, if we are in a servlet request context.

But if the call takes place in a different context, i.e. some arbitrary service (in my case a sling health check service), there is no ResourceResolver. This leads to the error   AEM_FRM_001_006:resourceResolver is Null which occures within the com.adobe.forms.aem.impl.RepositoryServiceImpl.

Other rendering services like the OutputService.generatePdfOutput(...) can be called not only by a string parameter to define a path of an xdp but also by a Document object containing the xdp. This allows the repository access to happen outside the rendering service and so the ResourceResolver can be handled under control of the calling programm.

The FormsService.renderPdfForm does not offer such a variant. Also it does not offer any possibility to hand in a ResourceResolver (at least as far I can see). 

Is there a possibility to somehow put an ResourceResolver into the FormsService?

Or is there a possibility to avoid the need of an ResourceResolver (but still be able to use xdp's stored within the repository)?

Aa allways, any help is appreciated :-)

Regards

Alex

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi Alex,

You can use com.adobe.granite.resourceresolverhelper.ResourceResolverHelper service to pass in a resourceResolver to the Forms/Output service. Normally, this gets automamtically set in a servlet context but if you are calling Forms/Output service in some other context (like workflows) this needs to be done explicitly.

 

Get reference to ResourceResolverHelper service

@Reference private ResourceResolverHelper  resourceResolverHelper; Use resourceResolverHelper.callWith method to pass resource resolver. Document serviceResponse = resourceResolverHelper.callWith(myResourceResolver, new Callable<Document/*Return type*/>() { @Override public Document call() throws Exception { /* <Call your stateful service API and return response> // The API implementation will now find a proper resolver when it calls ResourceResolverHelper.getResourceResolver() For example return formsService.renderPDFForm(....) */ } });

Thanks

Nitin

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

Hi Alex,

You can use com.adobe.granite.resourceresolverhelper.ResourceResolverHelper service to pass in a resourceResolver to the Forms/Output service. Normally, this gets automamtically set in a servlet context but if you are calling Forms/Output service in some other context (like workflows) this needs to be done explicitly.

 

Get reference to ResourceResolverHelper service

@Reference private ResourceResolverHelper  resourceResolverHelper; Use resourceResolverHelper.callWith method to pass resource resolver. Document serviceResponse = resourceResolverHelper.callWith(myResourceResolver, new Callable<Document/*Return type*/>() { @Override public Document call() throws Exception { /* <Call your stateful service API and return response> // The API implementation will now find a proper resolver when it calls ResourceResolverHelper.getResourceResolver() For example return formsService.renderPDFForm(....) */ } });

Thanks

Nitin