Skip to content

AEM JCR: Nodes, Node Types and Reading Properties in Java

The JCR in AEM: what a node is, cq:Page, dam:Asset and other node types, the /apps /libs /content layout, and reading properties in Java and HTL.

Written in December 2026.

On this page
  1. What is a JCR node?
  2. Which node types will you meet in AEM?
  3. How is the AEM repository laid out?
  4. How do you read JCR properties in AEM with Java?
  5. How do you read node properties in HTL?
  6. What can't you do with the JCR on AEM as a Cloud Service?

Everything AEM stores, from pages and assets to component code, configuration and users, is a node in one JCR tree, and every value your code reads is a property on one of those nodes. In Java you read them through Sling's Resource and ValueMap, in HTL through properties and pageProperties; the JCR Node API is the fallback. The implementation underneath is Apache Jackrabbit Oak, which implements JSR-283 (JCR 2.0). Oak keeps the tree in a node store and large binaries in a data store, the layer described in storage concepts in AEM 6.5. When AEM code reads a page title, it's reading a property of a node at a path such as /content/mysite/en/about/jcr:content.

What is a JCR node?

Each node has a path from the root, one primary type stored in jcr:primaryType, optional mixin types in jcr:mixinTypes, child nodes, and properties. A property is a name with a value. Values are typed, and the specification defines 12 property types, from String, Long, Boolean and Date to Binary and the reference types that point at other nodes. A property can also be multi-valued, which is how AEM stores a page's tags.

To see a real node, look at how your project stores one. In an archetype project's ui.content module, a page is a .content.xml file in FileVault's DocView format:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
    xmlns:cq="http://www.day.com/jcr/cq/1.0"
    xmlns:jcr="http://www.jcp.org/jcr/1.0"
    xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="cq:Page">
    <jcr:content
        jcr:primaryType="cq:PageContent"
        jcr:title="About us"
        navTitle="About"
        hideInNav="{Boolean}true"
        cq:tags="[mysite:topics/company,mysite:topics/team]"
        cq:template="/conf/mysite/settings/wcm/templates/page-content"
        sling:resourceType="mysite/components/page">
        <root
            jcr:primaryType="nt:unstructured"
            sling:resourceType="mysite/components/container">
            <hero
                jcr:primaryType="nt:unstructured"
                sling:resourceType="mysite/components/image"
                fileReference="/content/dam/mysite/team-photo.jpg"/>
        </root>
    </jcr:content>
</jcr:root>

Three nodes sit under the page node: jcr:content with the page properties, root, and hero, a component. A value without a prefix is a String; DocView writes other types as {Boolean}true or {Long}42, and a multi-valued property as a bracketed list.

Which node types will you meet in AEM?

The CND definitions below are from Adobe's node type reference, which is labelled for AEM 6.5; on AEM as a Cloud Service, check a node's jcr:primaryType in the Repository Browser before you depend on a definition.

Node typeWhere you see itWhat it allows
cq:PageEvery page under /contentExtends nt:hierarchyNode; holds its jcr:content child and child pages, and carries almost no properties itself
cq:PageContentThe page's jcr:contentExtends nt:unstructured, so any property; WCM reads jcr:title, cq:template, navTitle, hideInNav and others from here
nt:unstructuredComponent nodes, dialog content, most custom dataAny property, any child, ordered children
dam:AssetEvery file under /content/damA jcr:content child of type dam:AssetContent
dam:AssetContentAn asset's jcr:contentA metadata child for properties such as dc:title, and a renditions folder
sling:Folder, sling:OrderedFolderFolders in /content/dam, /conf and /appsA folder that also takes any property; the ordered variant keeps child order
cq:ComponentComponent definitions under /appsExtends nt:folder; holds the HTL script, dialog and jcr:title

Mind the split between cq:Page and cq:PageContent. Page properties live one level down, on jcr:content, so a query or a read on the page node itself finds no title. Assets follow the same pattern, with their metadata a further level down at jcr:content/metadata.

How is the AEM repository laid out?

By purpose, and on AEM as a Cloud Service also by who may write where. Adobe splits the tree into mutable and immutable areas:

PathHoldsCloud Service at runtime
/libsAEM product codeImmutable. Only Adobe deploys here, and you never change it on any version
/appsYour components, overlays of /libs, OSGi configurationImmutable; deployed from the ui.apps and ui.config packages
/confEditable templates and policies under /conf/<site>/settings/wcm, Content Fragment ModelsMutable
/contentSite pages, assets in /content/dam, Experience FragmentsMutable
/varData AEM generates while running, such as workflow instancesMutable
/homeUsers and groups, including service usersMutable
/oak:indexOak index definitionsMutable, but deployed as code with ui.apps

The /libs rule holds on AEM 6.5 too: copy what you need to change into /apps and change it there.

How do you read JCR properties in AEM with Java?

Through Sling's Resource and ValueMap, or AEM's Page API when the node is a page. Adobe's Java API best practices rank the APIs AEM first, Sling second, JCR third, and call broad use of Session and Node a code smell.

This OSGi service reads a page's navigation label with a service resource resolver, the way a scheduler or servlet would:

package com.example.mysite.core.services;

import java.util.Collections;
import java.util.Map;
import java.util.Optional;

import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.resource.ValueMap;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component(service = NavigationLabels.class)
public class NavigationLabels {

    private static final Map<String, Object> AUTH =
            Collections.singletonMap(ResourceResolverFactory.SUBSERVICE, "content-reader");

    @Reference
    private ResourceResolverFactory resolverFactory;

    /** The label a menu shows for a page; empty when the page is missing or hidden from navigation. */
    public Optional<String> labelFor(String pagePath) throws LoginException {
        try (ResourceResolver resolver = resolverFactory.getServiceResourceResolver(AUTH)) {
            Resource content = resolver.getResource(pagePath + "/jcr:content");
            if (content == null) {
                return Optional.empty();
            }
            ValueMap props = content.getValueMap();
            if (props.get("hideInNav", false)) {
                return Optional.empty();
            }
            String pageName = content.getParent().getName();
            return Optional.of(props.get("navTitle", props.get("jcr:title", pageName)));
        }
    }
}

ValueMap.get converts types for you and never throws for a missing property. Pass a default and you get its type back; pass a class and you get null when nothing's stored. Multi-valued properties come back as arrays, and a relative path reads a property of a descendant node, a form the Java API best practices page shows:

Calendar modified = props.get("cq:lastModified", Calendar.class);
String[] tags = props.get("cq:tags", new String[0]);
String heroImage = props.get("root/hero/fileReference", String.class);

The resolver is AutoCloseable, so try-with-resources closes it. A service resolver needs a service user. On AEM as a Cloud Service you create it with Repo Init, which deploys with your code to every environment. Put the script in ui.config, for example as /apps/mysite/osgiconfig/config/org.apache.sling.jcr.repoinit.RepositoryInitializer-mysite.config:

scripts=[
    "
    create service user mysite-content-reader

    set ACL on /content/mysite
        allow jcr:read for mysite-content-reader
    end
    "
]

Then map your bundle and the content-reader subservice to that user in an org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended factory configuration. The value uses the principal-name form in brackets, because Sling has deprecated mapping by user ID:

{
  "user.mapping": [
    "mysite.core:content-reader=[mysite-content-reader]"
  ]
}

Replace mysite.core with your core bundle's symbolic name. For a page, the Page API saves the jcr:content step:

PageManager pageManager = resolver.adaptTo(PageManager.class);
Page page = pageManager.getPage("/content/mysite/en/about");
if (page != null) {
    String title = page.getTitle();
    String navTitle = page.getNavigationTitle();
    boolean hidden = page.getProperties().get("hideInNav", false);
}

Page.getProperties() returns the page content's value map, and an empty map when there's no content node. In a component, a Sling Model does the same reads with annotations; see Sling Models in AEM.

When is the JCR Node API the right choice?

When you need what Sling doesn't expose: versioning, locking, mixins, node type checks, access control. For reading values it costs more code. Here's the tag read from above, done through javax.jcr:

import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Value;

String[] readTags(Resource content) throws RepositoryException {
    Node node = content.adaptTo(Node.class);
    if (node == null || !node.hasProperty("cq:tags")) {
        return new String[0];
    }
    Property prop = node.getProperty("cq:tags");
    if (!prop.isMultiple()) {
        return new String[] { prop.getString() };
    }
    Value[] values = prop.getValues();
    String[] tags = new String[values.length];
    for (int i = 0; i < values.length; i++) {
        tags[i] = values[i].getString();
    }
    return tags;
}

Every call can throw the checked RepositoryException. Calling getString() on a multi-valued property throws ValueFormatException, so you check isMultiple() first. And adaptTo(Node.class) returns null for any resource that isn't stored in the JCR, including the default in-memory resources of a unit test.

How do you read node properties in HTL?

With the global objects AEM puts in every script. properties is the current resource's value map, pageProperties is the current page's jcr:content, and inheritedPageProperties looks up the page's ancestors when the current page doesn't set a value. All three are backed by a ValueMap:

<!--/* the component's own node */-->
<h2 class="cmp-promo__title">${properties.jcr:title}</h2>

<!--/* the jcr:content of the page being rendered */-->
<p class="cmp-promo__section" data-sly-test="${pageProperties.navTitle}">${pageProperties.navTitle}</p>

<!--/* set once on a section's root page, read on every page below it */-->
<p class="cmp-footer__legal">${inheritedPageProperties.legalNotice}</p>

A colon in a property name works in dot notation, as in ${properties.jcr:title}. The other script variables, including currentPage and resource, are listed in HTL global objects and property access. For anything beyond printing a value, read it in a Sling Model and keep the script to getters.

What can't you do with the JCR on AEM as a Cloud Service?

Change /apps or /libs outside a deployment. Code reaches those paths only through Cloud Manager.

The second limit is tooling. CRXDE Lite is available on the author tier of development environments, not on stage or production, where the Developer Console's Repository Browser gives a read-only view. The local AEM SDK lets you write to /apps and /libs, so a fix made by hand in its CRXDE Lite can work on your machine and never reach the cloud. Anything the repository must contain goes into code: pages and folders in ui.content, users, ACLs and paths in Repo Init, and indexes under /oak:index, which you can draft with the Oak index definition generator.

More in Architecture and platform