Resolving StackOverflowError in AEM as a Cloud Service Pipeline Builds

In AEM as a Cloud Service, a recurring StackOverflowError occurs during pipeline builds. The error is traced to insufficient JVM stack size settings when compiling deeply recursive custom HTL code. Adjusting the JVM stack size parameter in the Maven configuration enables successful pipeline completion.

Description description

Environment

  • Product: Adobe Experience Manager as a Cloud Service(AEMaaCS) – Sites
  • Relevant constraints: Compilation of complex, recursive HTL code during pipeline builds

Issue/Symptoms

  • StackOverflowError appears repeatedly during pipeline build steps, especially Java compilation phases.
  • Pipeline failures occur even with previously successful source code commits.
  • Increasing or decreasing the JVM stack size (-Xss) impacts build outcomes.
  • Successful local builds do not guarantee success in Cloud Manager pipelines due to infrastructure resource limits.

Resolution resolution

To fix this issue, follow these steps:

  1. Identify all pom.xml files used in your project, including both root and submodule directories.
  2. Update the Maven compiler plugin configuration in each pom.xml file to set the JVM stack size parameter (-J-Xss) to 6M or 8M.
  3. Save and commit changes to all updated pom.xml files.
  4. Rerun the affected Cloud Manager pipeline after making these changes.
  5. If multiple pipelines are triggered simultaneously or one becomes stuck, wait for manual cancellation and resource cleanup before starting new executions.
  6. Verify that the build completes successfully without StackOverflowError.

Notes

  • Deep recursion in custom HTL code uses more stack memory than the default JVM allocation. Increasing -Xss helps, but if recursion grows, the error can return.
  • Refactoring HTL templates to minimize recursion is recommended for long-term stability.
  • Increasing -Xss to 6–8 MB remains within standard memory constraints of AEM as a Cloud Service build containers.
  • Avoid triggering additional pipelines while one is stuck to prevent resource contention and ensure proper cleanup before retrying builds.
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f