OSGi configuration must be deployed via code (content package), not manually edited in Felix Console. Easy PR review Git history tracking
OSGi Configuration
1. Configuration Convention
OSGi configuration must be deployed via code (content package), not manually edited in Felix Console.
- Easy PR review
- Git history tracking
- Consistency across environments
- Prevents configuration drift from manual operations
Felix Console is for quick debugging only; any changes must be "converted" back to .cfg.json files in the repository.
2. ui.config Directory Structure and Run Modes
Standard location:
Resolution Rule
AEM selects configuration based on specificity level from highest to lowest. When the same PID appears in multiple folders, the more specific folder takes precedence.
Example: If the same PID is placed in config/ and config.author.dev/, Author running with run modes author,dev will use the one from config.author.dev/.
Run Mode Folder Case Sensitivity
Use lowercase only. config.Author/ will be ignored.
3. File Naming Rules (PID)
Use .cfg.json for all files.
Singleton Configuration
Single configuration instance:
Factory Configuration
Multiple instances, use ~<id>:
<id> is for differentiation only and does not affect runtime logic.
Most Dangerous Error: PID Typo
One incorrect character in the filename = configuration is silently ignored. Prevention methods:
- Copy-paste the FQCN of component/
@DesignatePID from code - Add CI checks (see Section 10)
4. Data Types in .cfg.json
Complete example:
5. Typed Configuration (AEM 6.5 Standard)
Objective: Clear schema, UI support in /system/console/configMgr, type-safe injection.
5.1. @ObjectClassDefinition
5.2. @Designate + @Activate/@Modified
Add @Modified for AEM to apply configuration at runtime without bundle restart.
6. Secret Values on AEM 6.5 (on-prem)
Do not commit plaintext secrets to Git.
Common approach on AEM 6.5:
- Navigate to
http://<host>:4502/system/console/crypto - Encrypt secret → obtain string like
\{enc:...\} - Place
\{enc:...\}value in.cfg.json
Operational notes:
- The crypto key is instance-specific → migrating encrypted strings to another instance may fail decryption; often need to re-encrypt per environment.
- In production, manage secrets through operational processes (vault/secrets manager + automation). If not available, crypto console is the minimum baseline.
7. Felix Console—Use for Observation, Not "Production Configuration"
Commonly used URLs:
If edited in the console, configuration resides in JCR (typically under /apps/system/config) and will be overwritten on the next deployment.
8. Common AEM Configuration PIDs (AEM 6.5)
9. Pitfalls and Deployment Checklist
Pitfalls:
- Wrong run mode folder (placing publish config in
config.author/) - Missing
~idfor factory configuration - PID typo (configuration ignored)
- Missing
.cfg.json filter.xmldoes not include/apps/<app>/osgiconfig
Checklist:
- Files are in correct run mode folder
- Filename PID is exactly correct
- Factory configuration includes
~<id> - Package filter includes
.../osgiconfigpath - After deployment, verify configuration is applied in
/system/console/configMgr
10. Validate Configuration in CI (Reduce Production Errors)
Objective: Catch PID typos before deployment to any environment.
Practical approach:
- Parse filenames under
ui.config/.../osgiconfig/** - For singleton: get PID = filename (remove
.cfg.json) - For factory: get PID = part before
~ - Match PID against:
@ComponentFQCN (if using class-based PID)- or
@Designate(ocd=...)PID as defined by project convention
Failing the build when any PID does not match (or is not on the whitelist) significantly reduces "configuration not applied" errors.