AEM Scheduler Needs to auto-start after Deployment



Hi All,

Need AEM scheduler code in a bundle to pick osgi configuration and start execute automatically as soon as bundle is deployed.
Currently after deploying the bundle with scheduler code in it, every time have to save OSGI configuration for respective scheduler to get it start.

Any pointers across it would be really appreciated.

AEM AEM 6.3 AEM 6.3 Personalisation with Contexthub publisher issue AEM 6.5

Accepted Solutions (1)

Accepted Solutions (1)





Can you check if you used both Activate and Modified annotations for activate mathod

Sample Code -


protected void activate(final Config config) {
       myParameter = config.myParameter();


Yes have included. Using OSGi r6 annotations for configuration class but could observe that activate method is called but not run() method, not sure no logs of error are thrown.

Can you check following - 

  1. is your osgi configuartion is getting set as soon as bundle deployed? you can verify this by checking tick sign. 
    There may be chances only default values are getting set in osgi config but actual osgi config is not set.
  2. Can you try with the simple scheduler to check if it is code/config issue or instance issue e.g.
As soon as have deployed the bundle with scheduler removeModifier() & Activate() method are called. and after that nothing proceeds for execution. Once again after we save respective config file scheduler gets triggered. Always while deploying bundle it removing and activate is called. That`s it. Anymore inputs to resolve it would really help.
There is something wrong with your osgi config values/format in your code base. but if you want to manage osgi config using web console and don't wanted to overwrite by code then go to configMgr and delete the scheduler config and open scheduler config again and provide input and save it. It will not anymore overwritting config from code base. If you want to remove web console based config and want to use code based/repository based, again delete config from configMgr and deploy/save repository config

This is the config class code.


import org.osgi.service.metatype.annotations.AttributeDefinition;

import org.osgi.service.metatype.annotations.AttributeType;

import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(name = "Scheduler Configuration", description = "Configuration for mentioned in Scheduler ")

public @interface SchedulerConfigItr {

@AttributeDefinition(name = "Scheduler name", description = "Name of the scheduler", type = AttributeType.STRING)

public String schedulerName() default "Extract Asset Metadata Scheduler";

@AttributeDefinition(name = "Enabled", description = "True, if scheduler service is enabled", type = AttributeType.BOOLEAN)

boolean serviceEnabled() default true;

@AttributeDefinition(name = "Cron Expression", description = "Cron expression based on which scheduler runs", type = AttributeType.STRING)

public String cronExpression() default "0 0/1 * 1/1 * ? *";

@AttributeDefinition(name = "Folder Path", description = "Define folder path for extraction of assets metadata", type = AttributeType.STRING)

public String folderPath() default "/content/dam/abc";


Do let me know if anything is missing ?