Fix Inconsistencies by restarting AEM when SegmentNotFound Issue is reported in AEM 6.3


A SegmentNotFoundException is observed in the log files. Restarting AEM makes the error go away for one day (or longer).

For example:

29.09.2017 05:40:27.031 *ERROR* [ [1506663627021] GET /services/createvaultpackage HTTP/1.1] org.apache.jackrabbit.oak.segment.SegmentNotFoundExceptionListener Segment not found: 6c3c7910-6501-4c0a-af5d-6972006c6145. SegmentId age=654602216ms,segment-generation=17
org.apache.jackrabbit.oak.segment.SegmentNotFoundException: Segment 6c3c7910-6501-4c0a-af5d-6972006c6145 not found
at org.apache.jackrabbit.oak.segment.file.FileStore$
at org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager.internalGetNodeType(
at org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager.getNodeType(
at org.apache.jackrabbit.vault.packaging.impl.JcrPackageManagerImpl.initNodeTypes(
at org.apache.jackrabbit.vault.packaging.impl.JcrPackageManagerImpl.(
at org.apache.jackrabbit.vault.packaging.PackagingService.getPackageManager(
at customcode.VaultPackageFromSearchServlet.doGet(


AEM 6.3 and later versions with Online Compaction enabled


It can be caused due to long running JCR sessions along with online compaction.


Avoid keeping JCR sessions open for a long time.  To resolve the issue:

  1. Close the session and open a new one when required.
  2. Or periodically call session.refresh(true).

See this article for more details on the topic of long running sessions being an anti-pattern in AEM 6.x.