Repository unavailable errors occur during scheduled importer jobs in AEM as a Cloud Service

Adobe Experience Manager (AEM) as a Cloud Service scheduled importer jobs may intermittently fail with org.apache.sling.api.resource.LoginException: Repository unavailable when unclosed ResourceResolver instances cause resource exhaustion or high repository load temporarily prevents new sessions from being created. To resolve the issue, ensure that ResourceResolver instances are closed promptly, review logs and job load, verify service-user permissions, and monitor subsequent job runs.

Description description

Environment

Adobe Experience Manager as a Cloud Service (AEMaaCS), all versions

Issue/Symptoms

  • Scheduled custom importer jobs intermittently report: org.apache.sling.api.resource.LoginException: Repository unavailable
  • Errors may indicate that the ResourceResolver is null or that service-user login failed for a specific path.
  • Only some records in a job run may fail while others complete successfully.
  • The issue is more likely under higher load.
  • The issue may be reproducible in lower environments such as DEV or QA.

Root cause

The error is usually caused by resource exhaustion from unclosed ResourceResolver instances in custom code or by high repository load that temporarily prevents new sessions from being created.

Resolution resolution

Follow the steps below to resolve the issue:

  1. Review the custom importer code and ensure that every ResourceResolver instance obtained is closed after use. Avoid keeping ResourceResolver instances open for extended periods.
  2. Refactor the code so that ResourceResolver instances are created and closed as close as possible to their usage scope, for example, within a try-with-resources block or finally block.
  3. Enable DEBUG logging for org.apache.sling.jcr.resource and the custom service packages to monitor ResourceResolver lifecycle events and identify potential leaks.
  4. Check error.log and audit.log for warnings about unclosed ResourceResolver instances or resource exhaustion.
  5. Temporarily reduce the number of records processed per job run and monitor whether the error continues. If the error disappears under lower load, this suggests resource exhaustion or contention.
  6. Ensure that other heavy jobs, schedulers, or repository maintenance tasks don’t overlap with the importer job schedule.
  7. Verify that the service user used for ResourceResolver acquisition has the correct permissions and is properly mapped in the repository.
  8. After making the code changes, monitor subsequent job runs and confirm that the error no longer occurs.
recommendation-more-help
experience-cloud-kcs-help-kbarticles