Skip to main content

Command Palette

Search for a command to run...

🌳 JCR Repository in AEM Explained (Apache Jackrabbit Oak)

Published
β€’5 min read

Chapter 3 of AEM Learning Series β€” Understanding how AEM stores EVERYTHING.


πŸ“š What is JCR?

JCR = Java Content Repository

JCR is a Java specification (JSR-170 & JSR-283) that defines how content should be stored and accessed.

JCR Specification      β†’ Rulebook
Apache Jackrabbit Oak  β†’ Implementation
AEM                    β†’ Uses Oak to store all content

AEM does NOT use MySQL/Postgres like traditional apps.

It uses a hierarchical content repository.


🌲 AEM Does NOT Use Tables β€” It Uses a Tree

Traditional DB vs JCR

RELATIONAL DATABASE:
Table: employees
id | name  | age
1  | Shubh | 24
2  | Rahul | 28

JCR REPOSITORY:
/
└── content/
    └── mysite/
        └── en/
            └── home (NODE)
                β”œβ”€β”€ jcr:title = "Home Page" (PROPERTY)
                └── jcr:content (CHILD NODE)

πŸ‘‰ Think of JCR like a file system with superpowers.


🧩 Two Building Blocks of JCR


1️⃣ Node

A Node = Container (folder-like)

  • Has name + type (jcr:primaryType)

  • Can contain child nodes

  • Can contain properties

  • Has a unique path

Example path:

/content/mysite/en/home

2️⃣ Property

A Property = Key–Value pair

Supported data types:

TypeExample
STRING"Hello World"
LONG123
DOUBLE3.14
BOOLEANtrue
DATE2026-02-12
BINARYImages/PDF
PATH/content/dam/img.jpg
REFERENCEUUID reference

🏠 Complete AEM Page Node Structure

/content/mysite/en/about (cq:Page)
└── jcr:content (cq:PageContent)
    β”œβ”€β”€ jcr:title = "About Us"
    β”œβ”€β”€ sling:resourceType = "mysite/components/page"
    β”œβ”€β”€ cq:template = "/conf/.../template"
    └── root/container
        β”œβ”€β”€ text component
        └── image component

πŸ‘‰ Pages are just nodes in the repository.


🧠 Important Node Types

Node TypePurpose
cq:PageAEM page
cq:PageContentPage content
nt:unstructuredFlexible node
sling:FolderSling folder
dam:AssetDigital asset
rep:UserUser account
rep:GroupUser group

🏷️ Namespaces in JCR

PrefixOwner
jcr:JCR spec
nt:Node types
sling:Apache Sling
cq:Adobe (Day CQ legacy)
dam:Assets
rep:Users & permissions

Fun fact: AEM was originally Day CQ5 β†’ hence cq:.


⭐ Most Important Properties (Memorize!)

PropertyPurpose
jcr:primaryTypeNode type
jcr:titlePage title
cq:lastModifiedLast edit
sling:resourceTypeComponent renderer
cq:templatePage template
fileReferenceDAM asset path
cq:tagsPage tags

πŸ‘‰ Most important property: sling:resourceType

This tells AEM which component renders content.


πŸ’Ύ Storage Backend (Oak)

AEM uses Apache Jackrabbit Oak.

TarMK  β†’ Default, file-based, fast
MongoMK β†’ Clustered Author, MongoDB-backed

Node Store vs Data Store

StoreWhat it stores
Node StoreStructure + small properties
Data StoreImages, videos, PDFs

Locations:

crx-quickstart/repository/segmentstore/
crx-quickstart/repository/datastore/

πŸ” Querying JCR

1️⃣ QueryBuilder (Most Used)

path=/content/mysite
type=cq:Page
property=jcr:content/jcr:title
property.value=About Us

Test here:

/libs/cq/search/content/querydebug.html

2️⃣ JCR-SQL2

SELECT * FROM [cq:Page]
WHERE ISDESCENDANTNODE('/content/mysite')

3️⃣ XPath (Legacy)

/jcr:root/content/mysite//element(*, cq:Page)

πŸ“‚ Important Repository Paths

PathPurpose
/content/Website pages
/content/dam/Assets
/apps/Custom code
/libs/AEM core (never modify)
/conf/Templates
/home/users/Users
/var/Workflows
/oak:index/Search indexes

🚨 Never modify /libs/


🧠 Things to Remember

  • JCR = specification, Oak = implementation

  • Everything = Nodes + Properties

  • sling:resourceType = rendering component

  • TarMK = default storage

  • QueryBuilder = most common query method

  • /apps/ overlays /libs/

  • resolver.commit() persists changes


🎯 AEM Interview Questions β€” JCR (35 Q&A)


🟒 Basics

Q1. What is JCR?
Java Content Repository specification.

Q2. JCR vs Oak?
Spec vs implementation.

Q3. JCR building blocks?
Nodes and Properties.

Q4. JCR vs relational DB?
Tree vs tables.

Q5. JCR vs file system?
Rich metadata + querying.

Q6. Property types?
STRING, DATE, BINARY, PATH, etc.

Q7. Multi-value properties?
Yes (cq:tags).

Q8. Root node?
/

Q9. Node path example?
/content/mysite/en/home

Q10. JCR browser?
CRX DE Lite.


πŸ”΅ Node Types

Q11. jcr:primaryType?
Defines node type.

Q12. cq:Page vs cq:PageContent?
Page vs page content.

Q13. nt:unstructured?
Flexible node.

Q14. nt:folder vs sling:Folder?
Basic vs Sling-aware.

Q15. Namespaces?
Prefixes preventing conflicts.

Q16. Why cq: prefix?
Legacy Day CQ.

Q17. jcr:mixinTypes?
Extra node capabilities.


🟣 Structure

Q18. sling:resourceType?
Component renderer.

Q19. sling:resourceSuperType?
Component inheritance.

Q20. jcr:content?
Page content node.

Q21. Page structure?
cq:Page β†’ jcr:content β†’ components.

Q22. Key paths?
/content, /apps, /libs, /conf.


🟠 Storage

Q23. TarMK?
Default storage.

Q24. MongoMK?
Clustered storage.

Q25. Node vs Data Store?
Structure vs binaries.

Q26. Physical storage?
segmentstore + datastore folders.


πŸ”΄ Queries

Q27. Query methods?
QueryBuilder, SQL2, XPath.

Q28. QueryBuilder test URL?
querydebug.html.

Q29. SQL2 query example?
Find pages under path.

Q30. Query performance risk?
Traversal without indexes.


⚫ Advanced

Q31. JCR Observation?
Event listeners.

Q32. Versioning?
mix:versionable nodes.

Q33. JCR Session?
Repository connection.

Q34. session.save() vs resolver.commit()?
JCR vs Sling API.

Q35. Modify /libs/?
Never β€” use overlays.


πŸŽ‰ Final Summary

Understanding JCR = Understanding how AEM stores content.

AEM is basically:

  • Sling β†’ renders

  • OSGi β†’ runs

  • JCR β†’ stores

More from this blog

🌳 JCR Repository in AEM Explained (Apache Jackrabbit Oak)