Wasim's Site

AEM OSGi Config Generator

Generate AEM OSGi configurations. Enter a PID and typed properties, then export the modern .cfg.json and the legacy sling:OsgiConfig .content.xml.

OSGi Component

Target folder: ui.config/.../config/

Add Property

.cfg.json (recommended — AEM 6.5 & Cloud Service)

Save as com.example.core.MyServiceImpl.cfg.json

sling:OsgiConfig (.content.xml — legacy)

Save as com.example.core.MyServiceImpl.xml. The .cfg.json format above supersedes this.

Generating AEM OSGi Configurations

AEM runs on an OSGi container, and almost every service is tuned through OSGi configurations. Hand-authoring these files — getting the PID, the run-mode folder, and the typed value syntax exactly right — is fiddly and a common source of failed deployments. This generator produces both the modern .cfg.json format and the legacy sling:OsgiConfig XML so you can paste a correct configuration straight into your ui.config package.

.cfg.json vs. sling:OsgiConfig

The JSON OSGi configuration format (.cfg.json) is the current standard defined by Apache Sling and is what Adobe recommends for AEM 6.5 and AEM as a Cloud Service. It supersedes the older .cfg, .config, and XML-based sling:OsgiConfig resource definitions. Both are generated here — prefer .cfg.json for new work.

Value Types

String — plain text
String[] — array of strings (one per line)
Integer / Long — whole numbers
Double — decimal numbers
Boolean — true / false

How to Use This Generator

  1. Enter the PID: usually the fully-qualified class name of your component.
  2. Set a run mode (optional): the tool shows the matching config.<runmode> folder.
  3. Add properties: key, type, and value for each setting.
  4. Copy or download: drop the .cfg.json into your ui.config package.

Frequently Asked Questions

What is an OSGi configuration in AEM?
OSGi configurations supply property values to OSGi components (services) at runtime. They are targeted by a PID — usually the component's Java class name — and let you change behaviour per environment without changing code.
Should I use .cfg.json or sling:OsgiConfig XML?
Use .cfg.json. The JSON OSGi configuration format (defined by Apache Sling) is the current standard for both AEM 6.5 and AEM as a Cloud Service, and it supersedes the older .cfg, .config, and sling:OsgiConfig XML formats. This tool generates both so you can support legacy projects too.
How do run modes work in the file path?
Configurations live in run-mode-specific folders: config (all environments), config.author, config.publish, config.author.dev, etc. AEM applies the most specific matching folder. Enter a run mode and the tool shows the correct folder name.
What is a factory configuration?
Some services accept multiple named configurations (e.g. several scheduled jobs). These are factory configurations. The file name uses PID~alias for .cfg.json (or PID-alias for XML), where alias is your instance name. Toggle "Factory configuration" to set the alias.
How do I type values correctly?
Pick the type per property: String, String[] (array), Integer, Long, Double, or Boolean. The .cfg.json output uses native JSON types; the XML output uses AEM's typed syntax like {Boolean}true, {Long}10, and [a,b] for arrays.

Official Resources