‘Cannot derive user name for bundle and sub service’ error in Sling JobConsumer

This article explains how to resolve issues where Sling JobConsumer fails to process scheduled jobs in Adobe Experience Manager as a Cloud Service environments, resulting in errors such as ‘Cannot derive user name for bundle … and sub service …’. The solution involves verifying service user mapping, service user existence, and permissions.

Description description

Environment

  • Adobe Experience Manager (AEM) as a Cloud Service

Issue/Symptoms

  • Scheduled jobs remain unprocessed and stuck in the queue

  • Reports are not updated with new data

  • Job queue dashboard shows queued paths that are not consumed

  • Logs contain errors such as:

    Cannot derive user name for bundle [ bundle-symbolic-name] and sub service [ subservice-name]

Cause

This error occurs when the Sling JobConsumer attempts to obtain a service ResourceResolver using a subservice mapping that is missing, misconfigured, or lacks the necessary permissions in the environment. As a result, queued jobs cannot be processed.

Resolution resolution

To resolve the Cannot derive user name for bundle and sub service error and restore Sling JobConsumer processing, follow these steps:

  1. Verify the Sling service user mapping.

    • Ensure that the correct service user mapping is present in the environment configuration.
    • Confirm that the mapping matches the bundle symbolic name and subservice name used in your code.
    • Verify that the mapping does not reference an outdated or incorrect bundle symbolic name.

    Example mapping in an org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-* configuration:

    code language-none
    {
      "user.mapping": [
        "[ bundle-symbolic-name] :[ subservice-name] =[ service-user-name] "
      ]
    }
    

    Replace [ bundle-symbolic-name], [ subservice-name], and [ service-user-name] with your actual values.

  2. Validate the service user’s existence and permissions.

    • Confirm that the service user specified in the mapping exists in the environment.

    • Ensure that the service user has the permissions required by your job on the applicable paths:

      • /content/dam
      • /var
      • /home
      • Any custom paths used by your job, such as /var/yourproject/attestation
    • Check the error logs for permission or resource resolver login issues.

  3. Check bundle deployment and activation.

    • In the AEM System Console (/system/console/bundles), verify that the relevant bundle is deployed and active.
    • If the bundle is missing, deploy it. If it is inactive, resolve the OSGi issues preventing activation.
  4. Review the JobConsumer and scheduler configuration.

    • Confirm that the Sling JobConsumer and scheduler are registered and active.
    • Ensure that lifecycle code, such as @Deactivate methods, does not unschedule jobs globally during pod shutdowns, as this can affect clustered environments.
  5. Test and monitor job processing.

    • After correcting the mappings and permissions, re-queue the affected paths and monitor job execution.
    • Check the logs for successful job processing and confirm that the Cannot derive user name for bundle and sub service error no longer appears.
recommendation-more-help
experience-cloud-kcs-help-kbarticles