Fragments not resolving in Output Service OSGi API in AEM

In Adobe Experience Manager Forms as a Cloud Service (AEMFaaCS), fragment references within XDP files fail to resolve when using the Output Service OSGi API. This issue occurs when relative paths aren’t interpreted correctly due to improper configuration of the content root or incorrect fragment references. To resolve the issue, configure the content root and use correct relative paths.

Description description

Environment

  • Product: Adobe Experience Manager Forms as a Cloud Service (AEMFaaCS)
  • Instance: Development

Issue/Symptoms

  • Errors such as javax.jcr.PathNotFoundException and javax.jcr.RepositoryException appear in logs.
  • Fragment paths embedded in XDP files with relative references are not resolved as expected.

Resolution resolution

Follow these steps to resolve fragment resolution issues in AEM Forms Output Service:

  1. Set the contentRoot parameter to the top-level directory that contains both main XDPs and fragment folders. For example, if your main XDP folder is /content/dam/formsanddocuments/main-xdps and your fragments are located under /content/dam/formsanddocuments/fragments, set the content root to /content/dam/formsanddocuments/.  Refer to Generating pdf documents using fragments.
  2. In your main XDP file, provide relative paths for fragments based on the content root set in step 1. For instance, if a barcode fragment is located at /content/dam/formsanddocuments/fragments/barcode.xdp, use ./fragments/barcode.xdp as the reference path in your main XDP.
  3. Do not use absolute paths like /content/dam/formsanddocuments/fragments/xdp/barcode.xdp.
  4. Avoid referencing paths that navigate upwards from the main XDP location (for example, ../../barcode.xdp).
  5. When calling outputService.generatePDFOutput(templateName, data, options), provide the full path of your main XDP file (for example, crx:///content/dam/formsanddocuments/af-personal/main-xdps/CM201-0822.xdp) as the template name.
  6. After implementing these adjustments, test all scenarios to ensure consistent behavior across different XDPs and fragments.

Output Service in the AEM User Guide.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f