π³ JCR Repository in AEM Explained (Apache Jackrabbit Oak)
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:
| Type | Example |
| STRING | "Hello World" |
| LONG | 123 |
| DOUBLE | 3.14 |
| BOOLEAN | true |
| DATE | 2026-02-12 |
| BINARY | Images/PDF |
| PATH | /content/dam/img.jpg |
| REFERENCE | UUID 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 Type | Purpose |
cq:Page | AEM page |
cq:PageContent | Page content |
nt:unstructured | Flexible node |
sling:Folder | Sling folder |
dam:Asset | Digital asset |
rep:User | User account |
rep:Group | User group |
π·οΈ Namespaces in JCR
| Prefix | Owner |
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!)
| Property | Purpose |
jcr:primaryType | Node type |
jcr:title | Page title |
cq:lastModified | Last edit |
sling:resourceType | Component renderer |
cq:template | Page template |
fileReference | DAM asset path |
cq:tags | Page 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
| Store | What it stores |
| Node Store | Structure + small properties |
| Data Store | Images, 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
| Path | Purpose |
/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 componentTarMK = 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