For AI agents: the complete documentation index is available at https://nhanbe.id.vn/llms.txt, the full documentation bundle is available at https://nhanbe.id.vn/llms-full.txt, and this page is available as Markdown at https://nhanbe.id.vn/aem/articles/operation/aem-debug-notes.md.

AEM Debug Notes

AEM 6.5 debug URLs, hidden URL parameters, JCR JSON selectors, Sling resolution tools, logs, workflow and replication RCA shortcuts.

AEM Debug Notes

Warning

Chỉ dùng trên author/local. Publish phải chặn /system/console, /crx/de, /bin/querybuilder.json, *.infinity.json, ?debug=*, /etc/replication, /dispatcher/invalidate.cache.

Phạm vi: AEM 6.5 on-premise. AEM as a Cloud Service không có /system/console, /crx/de và Classic UI — dùng Cloud Manager/Developer Console.

compo

bin/browser.html curl -O https://repo1.maven.org/maven2/com/composum/nodes/composum-nodes-package/4.3.5/composum-nodes-package-4.3.5.zip Central Repository: com/composum/nodes/composum-nodes-aem-package/4.3.5

<dependency>
    <groupId>com.composum.nodes</groupId>
    <artifactId>composum-nodes-package</artifactId>
    <version>4.3.5</version>
</dependency>

1. Logs

Log mặc định nằm trong crx-quickstart/logs/.

FileNội dung
error.logException, stack trace, lỗi bundle/OSGi
request.logRequest/response, user, status, thời gian xử lý
access.logHTTP access: IP, method, path, status, bytes
audit.logThay đổi admin/user/security
history.logAi tác động content nào, lúc nào
stdout.log / stderr.logJVM stdout/stderr, startup
upgrade.logUpgrade/service pack

Độ nghiêm trọng tăng dần: TRACE → DEBUG → INFO → WARN → ERROR → FATAL.

  • /system/console/slinglog — ★ thêm logger theo package/class, đổi level, tạo log file riêng, không cần restart.
  • /system/console/status-slinglogs — xem/tải log trực tiếp từ web console.
tail -f crx-quickstart/logs/error.log
grep -iE "exception|error" crx-quickstart/logs/error.log
grep "GET /content/site" crx-quickstart/logs/request.log

2. URL parameters

ParamTác dụng
?wcmmode=disabled|preview|edit|designĐổi WCM mode; disabled = render như publish, bỏ editor chrome
?debugClientLibs=true★ Load từng file JS/CSS chưa minify; xem file nào được include
?debug=messages★ Hiện log message trên page
?tags=<logger>Lọc log khi dùng với ?debug=messages
?debug=layout★ Chi tiết component/layout (Classic UI)
#cf/★ Bỏ Content Finder khỏi URL khi refresh (Classic UI)
?wcmmode=disabled
?wcmmode=disabled&debugClientLibs=true
?wcmmode=disabled&debug=messages&tags=com.day.cq.replication
  • ?wcmmode=disabled không thay thế publish thật: author khác run mode, không có Dispatcher/CDN.
  • ?debugClientLibs=true có thể phá editor; load page ngoài editor.

3. JCR JSON — đọc cấu trúc không cần CRXDE

URLKết quả
/content/site/en/page.jsonNode + properties (depth mặc định)
/content/site/en/page.1.jsonThêm 1 cấp con
/content/site/en/page.2.jsonThêm 2 cấp con
/content/site/en/page.infinity.jsonToàn bộ subtree — có thể rất lớn
/content/site/en/page.tidy.infinity.jsonJSON đã format
/content/site/en/page/jcr:content.jsonjcr:content của page
/content/site/en/page/jcr:content/root.infinity.jsonCây component
/content/dam/site/img.jpg/jcr:content/metadata.jsonMetadata asset
/content/dam/site/img.jpg/jcr:content/renditions.jsonDanh sách renditions
/content/dam/site/cf/jcr:content/data/master.jsonContent Fragment data

Hidden selectors

Selector / URLDùng để
.tidyFormat JSON dễ đọc
.harrayChild nodes trả về dạng array, giữ thứ tự
.V.json★ Version info của node (VersionInfoServlet; mặc định disabled)
;v=<version>★ Đọc đúng JCR version, ví dụ page.tidy.json;v=1.0
.cq_dialog.html / .cq_design_dialog.html★ Mở dialog/design dialog của component standalone
.model.json★ Sling Model exporter (nếu component có @Exporter)
/system/sling/info.sessionInfo★ JCR session hiện tại: user, workspace, ... (.json/.txt)
GET /content/site/en/page.tidy.2.json
GET /content/site/en/page/jcr:content/root/container/text.cq_dialog.html
GET /content/site/en/page/jcr:content/root/container/cta.model.json
GET /content/site/en/page.tidy.json;v=1.0
GET /system/sling/info.sessionInfo.json
  • Dùng .N.json thay vì .infinity.json khi chỉ cần vài cấp.
  • .infinity.json, .tidy.json, .V.json phải bị chặn trên publish.
  • Giới hạn json.maximumresults và tắt HTML/XML renderer trong /system/console/configMgr/org.apache.sling.servlets.get.DefaultGetServlet; không tắt JSON vì AEM cần.

4. Sling & UI debug

URLDùng để
/system/console/jcrresolver★ Test resolve/map URL, vanity URL, redirect, search path
/system/console/servletresolver?url=/content/site/en/page.html&method=GET★ Tách path/selectors/extension/suffix và liệt kê script/servlet sẽ xử lý
/system/console/servletresolver.json?url=...Cùng dữ liệu ở dạng JSON
/system/console/requests★ Request gần đây: status, thời gian, script/include chain
/system/console/tracer★ Trace log theo request, không cần bật DEBUG toàn cục
/system/console/adapters★ Adapter factory — kiểm tra adaptTo()/Sling Model
/system/console/slingcaconfig★ Context-aware config đang resolve cho một path
/libs/granite/ui/content/dumplibs.htmlClientlib categories, dependencies, đường dẫn
/libs/wcm/core/content/sites/components.htmlComponent console: tìm resource type/path

Thứ tự debug khi page render sai:

  1. servletresolver — đúng script/servlet chưa?
  2. requests — include chain có component nào?
  3. .json / .infinity.json — property có đúng không?
  4. cq_dialog.html — dialog có map đúng field không?
  5. dumplibs.html + ?debugClientLibs=true — clientlib nào thiếu?
  6. components / adapters — component hoặc Sling Model có được resolve không?

URL mapping sai: dùng jcrresolver, kiểm tra /etc/map, sling:vanityPath, redirect và search path.

5. OSGi & runtime

URLDùng để
/system/console/bundlesBundle state; Resolved thường do thiếu import
/system/console/componentsDS component; Unsatisfied do thiếu reference
/system/console/configMgrOSGi config; mở trực tiếp /system/console/configMgr/<pid>
/system/console/slingevent★ Sling Jobs: queue, scheduled jobs, failed/queued count, suspend/resume/drop all
/system/console/healthcheckHealth check
/system/console/jmxJMX; mở trực tiếp /system/console/jmx/<ObjectName>
/system/console/memoryusage / /profiler / /status-ThreadsHeap, CPU profile, thread dump
/system/console/depfinderPackage/class nào do bundle nào export
/system/console/productinfoVersion, service pack, hotfix
/libs/granite/operations/content/...systemoverview.html, healthreports/healthreportlist.html, diagnosis.html, maintenance.html
/system/console/jmx/java.lang%3Atype%3DRuntime
/system/console/jmx/com.adobe.granite%3Atype%3DRepository
/system/console/jmx/org.apache.jackrabbit.oak%3Aname%3DOak+Query+Statistics%2Ctype%3DQueryStat
  • Bundle Resolved: click bundle → Imports/Wiring; dùng depfinder để tìm exporter.
  • DS Unsatisfied: click component → xem reference nào đang thiếu.
  • Config: kiểm tra cả config.author/config.publish và context-aware config.
  • Publish hardening: tắt com.day.cq.wcm.core.impl.WCMDebugFilter; đặt WCM Mode = disabled cho Day CQ WCM Filter.

6. Workflow

Console: /libs/cq/workflow/content/console.html

TabDùng để
ModelsXem định nghĩa model
InstancesWorkflow đang chạy, step hiện tại
ArchiveLịch sử workflow đã xong
FailuresLỗi, retry, terminate
LauncherVì sao workflow tự chạy
Dữ liệuPath JCR
Instance/var/workflow/instances
Model/var/workflow/models, /conf/global/settings/workflow/models
Launcher/conf/global/settings/workflow/launcher

Một instance có cấu trúc:

/var/workflow/instances/<server>/<id>/
├── data/metaData
├── data/payload
├── history
└── workItems
  • Failures → đọc error → sửa nguyên nhân → Retry; không cứu được thì Terminate.
  • Không xoá node /var/workflow/instances bằng tay; dùng Workflow Purge trong /libs/granite/operations/content/maintenance.html.
  • Instance treo nhiều làm phình repository và chậm; kiểm tra số lượng khi RCA performance.

7. Replication, audit, Dispatcher

URLDùng để
/etc/replication/agents.author.htmlAgent author: queue, log, test connection
/etc/replication/agents.publish.htmlAgent publish/reverse
/var/audit/com.day.cq.replicationAudit replication
/var/audit/com.day.cq.wcm.core.pageAudit page events
/etc/reports/auditreport.htmlAudit report (Classic)

Page properties:

  • cq:lastReplicated, cq:lastReplicatedBy, cq:lastReplicationAction
  • jcr:lastModified, jcr:lastModifiedBy

Replicate bằng HTTP (author, cần CSRF):

TOKEN=$(curl -s -u admin:admin http://localhost:4502/libs/granite/csrf/token.json | jq -r .token)
curl -u admin:admin -X POST \
  -H "CSRF-Token: $TOKEN" \
  -d "path=/content/site/en/page" \
  -d "cmd=Activate" \
  http://localhost:4502/bin/replicate.json

Dispatcher flush:

curl -i -X POST "http://dispatcher/dispatcher/invalidate.cache" \
  -H "CQ-Action: Activate" \
  -H "CQ-Handle: /content/site/en/page" \
  -H "Content-Type: application/octet-stream" \
  -H "Content-Length: 0"

RCA "page không lên publish":

  1. Agent queue có blocked? Item đầu queue lỗi gì?
  2. Test Connection tới publish.
  3. Agent log: path đã gửi chưa, publish trả gì?
  4. cq:lastReplicated + audit.
  5. Queue OK mà vẫn thiếu → kiểm tra Dispatcher cache/CDN.

8. Version, audit, Timewarp

Thao tácVị trí
Version storage/jcr:system/jcr:versionStorage
Xem/restore versionPage → Timeline → Versions; hoặc Sites → Restore
Audit page/replication/var/audit/...
Audit report/etc/reports/auditreport.html
TimewarpPage editor → Timewarp: xem trạng thái publish tại một thời điểm
LaunchesSites → Launches: preview nội dung tương lai
  • Timewarp dùng version của page; chỉ read-only; code/CSS/asset không được version hóa.
  • "Mất nội dung": so timestamp version với audit và history.log.
  • Page đã move: version trước move có thể không preview được.

9. QueryBuilder & Oak

Query debugger: /libs/cq/search/content/querydebug.html

/bin/querybuilder.json?path=/content/site&type=cq:Page
  &property=jcr:content/sling:resourceType
  &property.value=site/components/page
  &p.limit=20
ParamDùng để
p.limit=-1Lấy hết — cẩn thận với tree lớn
p.offset=20Phân trang
p.hits=fullTrả full node + child
p.hits=selectiveChỉ trả property được chọn
p.properties=jcr:path jcr:titleChọn property với selective; phân tách bằng space (%20 trong URL)
p.nodedepth=2Giới hạn depth với full
p.guessTotal=trueƯớc lượng total, nhanh hơn
orderby=@jcr:content/cq:lastModified + orderby.sort=descSort, mới nhất trước
property.operation=equals|unequals|like|existsSo sánh

Nhiều predicate:

/bin/querybuilder.json?path=/content/site&type=cq:Page
  &1_property=jcr:content/cq:template
  &1_property.value=/conf/site/settings/wcm/templates/article
  &2_property=jcr:content/cq:lastReplicated
  &2_property.operation=exists
  &p.hits=selective
  &p.properties=jcr:path%20jcr:title%20cq:lastReplicated
  &p.limit=50
  • /libs/granite/operations/content/diagnosistools/queryPerformance.html — slow query/explain.
  • /libs/granite/operations/content/diagnosistools/indexManager.html — index status/reindex.
  • /oak:index — index definition.
  • JMX Oak Query Statistics — xem mẫu query chậm.

10. RCA nhanh

  1. Author vs publish: ?wcmmode=disabled, so sánh HTML.
  2. Log: error.log / request.log; bật slinglog hoặc ?debug=messages.
  3. Content: .json / .infinity.json; cq_dialog.html; sling:resourceType.
  4. Render: servletresolver → requests → components / adapters.
  5. Clientlib: dumplibs + ?debugClientLibs=true.
  6. Publish: agent queue/log → cq:lastReplicated → audit → Dispatcher flush.
  7. Performance: queryPerformance → indexManager → JMX → thread dump/profiler.
  8. Workflow: Failures → Sling Jobs (slingevent) → purge.
  9. Content loss: versionStorage + audit + history.log.

Đọc thêm

Others

Dưới đây là các URL, bundle và công cụ mình hay dùng để debug trên AEM 6.5 on-prem. Base URL là http://localhost:4502 và cần đăng nhập admin. Vài đường dẫn trong Operations có thể khác nhẹ tùy Service Pack, nên bạn kiểm tra lại trên instance của mình.

1. Felix Web Console (/system/console)

URLDùng để
/system/console/bundlesXem trạng thái bundle (Active/Installed/Resolved). Lọc bundle lỗi bằng ô search hoặc bundles.json
/system/console/configMgrXem và sửa OSGi config, tìm theo PID. Có nút "Source" xem file config thực tế
/system/console/componentsXem OSGi component (SCR): ai Active/Unsatisfied và thiếu reference nào
/system/console/servicesXem các OSGi service đã đăng ký, kèm bundle sử dụng
/system/console/depfinderTìm bundle nào export package X, hữu ích khi gặp lỗi unresolved import
/system/console/status-slingsettingsXem run modes, Sling home, instance info
/system/console/status-ConfigurationsDump toàn bộ config hiện tại
/system/console/status-osgi-installerXem OSGi Installer, config/bundle nào đang chờ cài hoặc lỗi
/system/console/memoryusageXem heap/GC, tạo heap dump, chạy GC
/system/console/status-jstackThread dump (Threads)
/system/console/jmxTruy cập MBean (xem mục 5)
/system/console/healthcheckChạy các health check, lọc theo tag
/system/console/slingeventXem Sling Jobs, queue, job bị kẹt/failed
/system/console/jcrresolverTest URL được resolve thành resource nào, kèm Sling Mapping (/etc/map)
/system/console/servletresolverNhập path và method để biết servlet/script nào xử lý
/system/console/status-slingmodelsXem Sling Models đã đăng ký, adapter, implementation
/system/console/requestsRequest gần đây, kèm RequestProgressTracker (thời gian từng bước render)
/system/console/slinglogCấu hình logger/log writer (xem mục 3)
/system/console/tracerSling Log Tracer (xem mục 3)

Gần như mọi trang đều có thể thêm .json để gọi bằng script, ví dụ:

curl -u admin:admin http://localhost:4502/system/console/bundles.json

2. JCR và Resource

URLDùng để
/crx/de/index.jspCRXDE Lite: duyệt node, xem property, query SQL2/XPath
/crx/explorer/index.jspCRX Explorer: repository info, search, node type admin
/crx/packmgr/index.jspPackage Manager: build/install/download package
/crx/repository/crx.defaultWebDAV vào repository (mount hoặc dùng vlt)
/system/sling/info.sessionInfo.jsonXem session hiện tại đang đăng nhập bằng user nào
/bin/browser.htmlComposum Nodes (nếu cài thêm): duyệt JCR/Sling rất tiện

Xem dữ liệu node bằng Sling selector (không cần CRXDE):

/content/<site>/en/home.json              # properties của node
/content/<site>/en/home.1.json            # kèm con cấp 1
/content/<site>/en/home.infinity.json     # toàn bộ cây (cẩn thận node lớn)
/content/<site>/en/home.tidy.2.json       # JSON dễ đọc, sâu 2 cấp
/content/<site>/en/home.model.json        # output Sling Model Exporter (nếu có)
/content/<site>/en/home.html?wcmmode=disabled   # xem như publish, không có edit overlay

3. Log và Trace

Vị trí file log: crx-quickstart/logs/

FileNội dung
error.logLog ứng dụng, nơi cần xem đầu tiên
request.log / access.logRequest vào, thời gian xử lý, status
audit.logSự kiện audit
stdout.log / stderr.logOutput lúc khởi động và lỗi JVM
upgrade.logLịch sử upgrade

Cách bật log cho package của bạn:

  1. Vào /system/console/slinglog (hoặc configMgr → "Apache Sling Logging Logger Configuration").
  2. Add logger: Log Level DEBUG, Logger com.yourcompany, Log File logs/project.log.

Sling Log Tracer dùng để ghi log theo từng request, không cần mở DEBUG toàn hệ thống:

  1. Trong configMgr, bật "Apache Sling Log Tracer" (tick Enabled).
  2. Gửi request kèm header Sling-Tracer-Record: true (dùng plugin ModHeader hoặc curl).
  3. Xem kết quả trong /system/console/tracer theo Request ID.
  4. Rất hợp để xem query Oak thực sự chạy gì: thêm logger org.apache.jackrabbit.oak.query ở mức DEBUG.

4. Query và Index

URLDùng để
/libs/granite/operations/content/diagnosistools/queryPerformance.htmlChạy query, xem explain plan, slow/popular queries
/libs/granite/operations/content/diagnosistools/indexManager.htmlXem các Oak index, trạng thái reindex
/libs/cq/search/content/querydebug.htmlQueryBuilder Debugger: thử predicate, xem XPath sinh ra
/bin/querybuilder.json?path=/content&type=cq:Page&p.limit=10Gọi QueryBuilder trực tiếp
/oak:index (trong CRXDE)Xem/sửa custom index definition

Gợi ý query kiểm tra nhanh trong Query Performance: nếu plan có traversal trên cây lớn thì thiếu index, nên tạo Oak index cho property đó.

5. JMX (/system/console/jmx)

MBeanDùng để
org.apache.jackrabbit.oak: QueryStatSlow query, popular query
org.apache.jackrabbit.oak: IndexStats / asyncTrạng thái async indexing (indexing đang trễ?)
org.apache.jackrabbit.oak: RepositoryStatsSố liệu session, query, observation
org.apache.jackrabbit.oak: SegmentNodeStoreDung lượng segment, compaction
com.adobe.granite: RepositoryThông tin repository, mở/đóng session
java.lang: Threading / MemoryThread, heap

6. Operations, Audit, Replication, Workflow

URLDùng để
/libs/granite/operations/content/diagnosistools.htmlTrang tổng Diagnosis (log tailer, download logs, query performance, index manager)
/libs/granite/operations/content/systemoverview.htmlSystem Overview: tổng quan sức khỏe, trạng thái
/libs/granite/operations/content/maintenance.htmlMaintenance: version purge, audit log purge, workflow purge, compaction
/etc/replication/agents.author.htmlReplication agents: queue, test connection, log từng agent
/etc/replication/agents.author/publish/jcr:content.log.htmlLog chi tiết của agent publish
/libs/cq/workflow/content/console.htmlWorkflow console: instances, models, failures
/system/healthSling Health Check dạng text/JSON, lọc theo ?tags=...

Các node JCR hữu ích khi audit:

  • /var/audit: audit event (page, asset, replication).
  • /var/workflow/instances: workflow instance đang chạy/đã chạy.
  • /var/eventing/jobs: job queue (job kẹt thường nằm ở đây).
  • /var/replication: replication queue.

7. User và Permission

URLDùng để
/libs/granite/security/content/useradmin.htmlUser admin (Touch UI)
/libs/granite/security/content/groupadmin.htmlGroup admin
/libs/granite/security/content/permissions.htmlPermissions: xem quyền hiệu lực của user/group trên từng path
/useradminUser admin classic (tìm user/group nhanh)

Khi debug "user không thấy/không sửa được node", công cụ Permissions và CRXDE (tab Access Control) là hai chỗ kiểm tra nhanh nhất.

8. Bundle và component nên nhìn khi có sự cố

Trong /system/console/bundles, lọc theo từ khóa:

  • Apache Jackrabbit Oak Core: lỗi repository, index, query.
  • Apache Sling Models Impl: model không inject được.
  • Apache Sling Scripting HTL: lỗi HTL, Use-API.
  • Apache Sling Event Implementation: job/queue lỗi.
  • Apache Sling JCR Resource Resolver: lỗi mapping, resource resolver.
  • Adobe Granite ... / Day CQ WCM ...: lỗi component, page, template.
  • Bundle của bạn (<project>.core): kiểm tra Active; nếu Installed, xem Imported Packages để biết thiếu package nào, rồi dùng depfinder tìm bundle export.

9. Một số "combo" debug thực tế

Tình huốngLàm gì
Bundle của project ở trạng thái Installedbundles → mở bundle → xem unresolved import → depfinder
Component không render/Sling Model nullcomponents (có Unsatisfied?) → status-slingmodels → servletresolver
URL ra sai trang/mapping saijcrresolver nhập URL, xem resource được resolve
Trang chậmrequests xem progress tracker → Query Performance → JMX QueryStat
Query chậmQuery Performance (explain) → Oak index; dùng Tracer để bắt query thật
Publish không nhận nội dungReplication agent queue + log; /var/replication; /var/eventing/jobs
Workflow kẹtWorkflow console → Failures; slingevent xem queue
Instance chậm/treomemoryusage, status-jstack, JMX threading

10. Lưu ý bảo mật

Các endpoint /system, /crx, /libs/granite/operations, /bin/querybuilder.json, .infinity.json... chỉ dành cho Author/local. Trên Publish phải chặn qua Dispatcher filter (deny) và không expose ra Internet.

Nếu bạn muốn, mình sẽ làm một trang HTML (bookmark dashboard) gom toàn bộ link này, có ô nhập base URL (local/dev/uat) để bấm là mở đúng tool. Bạn có muốn mình làm không?