Skip to content

Instantly share code, notes, and snippets.

Andrew Khoury andrewmkhoury

Block or report user

Report or block andrewmkhoury

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 1-Oak SegmentNotFoundException repair

The objective here is to find all SegmentNotFoundException type corruption and remove it (as we don't have a valid backup)

Before running any of the below steps we created an index.json file (see the file below) which contains only the index definitions of the corrupted indexes.

  1. This generates the file indexing-results\index-definities.json
java -Xmx8g -jar oak-run-1.8.12.jar index --fds-path=crx-quickstart\repository\datastore crx-quickstart\repository\segmentstore --index-definitions
  1. From that file we copied only the definitions we needed and created index.json (file attached here )
andrewmkhoury / 1 - Fix
Last active Feb 17, 2020
Fix Corrupt Jackrabbit Oak Version Histories
View 1 - Fix


When deleting versions from Apache Jackrabbit Oak you observe errors in the logs similar to the one below:

java.lang.NullPointerException: null
        at org.apache.jackrabbit.oak.plugins.version.ReadWriteVersionManager.removeVersion(

For the full stack see error.txt below.


There are a number of scripts available for validating and fixing Apache Oak version histories. The steps for running these are below.

andrewmkhoury /
Last active May 23, 2019
How to disable Text Extraction in Apache Jackrabbit Oak
  1. Find the location of the oak-lucene jar file:
    find crx-quickstart/launchpad/felix -name "" -exec grep oak-lucene {} \; -print
    Example output:
  2. Take the second line of the output and remove from the path, following the example above, we have:
andrewmkhoury / 1 Instructions - Find Oak
Last active Feb 20, 2020
Oak count node check in script console - use while AEM / Oak is running
View 1 Instructions - Find Oak
  1. Go to http://host:port/system/console/bundles and install these two bundles
  2. Go to http://host/system/console/configMgr/
  3. Add org.apache.felix.webconsole.plugins.scriptconsole to "Whitelist regexp" and save
  4. After the two bundles fully install then go to http://host:port/system/console/slinglog
  5. Click "Add New Logger" and set log level to "Info", "Log File" to "logs/countnodes.log", and "Logger" to "countNodes.groovy"
  6. Save the log file config
  7. Go to http://host:port/system/console/sc
  8. Select "Groovy" as the language
andrewmkhoury /
Last active Feb 21, 2018
Script to set the rep:externalId if it is missing in AEM due to users being migrated from an older version of CQ/AEM
andrewmkhoury /
Last active Jan 28, 2020
oak-run Groovy script to reset the Adobe AEM "admin" user password

To run this script:

  1. Download the oak-run version matching the version of Oak installed in AEM:
  2. Download the attached adminUtils.groovy script
  3. Upload the adminUtils.groovy script and the oak-run jar to your AEM server
  4. Run the command to start the oak-run console. For example:
    java -Xmx2048m -jar /tmp/oak-run-1.6.1.jar console /app/aem/aem63/crx-quickstart/repository/segmentstore --read-write
  5. Once the oak-run console is open then load the groovy script using this command:
andrewmkhoury /
Last active Jul 15, 2019
Migrating AEM Users, Groups and ACLs between instances
  1. Migrate users and groups (If users were not imported automatically via LDAP) Package users and groups (2 separate packages) on the old system (excluding admin and anonymous OOTB users)
    1. Go to CRXDE lite app /crx/de/index.jsp and log in as admin user (on the old system)
    2. Go to "Tools" => "Query"
    3. In the bottom "Query" box enter this query to find the admin user: /jcr:root/home/users//element(*,rep:User)[@rep:principalName="admin"]
    4. Click "Execute" and copy the path of the admin user node in the results to a text file
    5. Repeat step 3 with a query for anonymous user: /jcr:root/home/users//element(*,rep:User)[@rep:principalName="anonymous"]
    6. Click "Execute" and copy the path of the anonymous user node in the results to a text file (so now you should have two paths, one for "admin" and one for "anonymous")

JavaScript Notes


== vs ===

  • == only compares values
  • === compares values + type


console.log(false == '0')
andrewmkhoury / Oak Datastore
Last active Nov 2, 2019
Oak Datastore Consistency Check
View Oak Datastore
  1. Download the oak-run version that matches what is installed from
  2. Stop all AEM instances in cluster
  3. Upload the oak-run jar to the AEM server
  4. Run this command to start the oak console
  • on TarMK:
   java -Xmx4g -jar target/oak-run.jar console --quiet /path/to/segmentstore
  • For MongoMK run this:
andrewmkhoury / Dump datastore
Last active Jun 14, 2018
How to dump the list of datastore references in Oak``
View Dump datastore
  1. Download oak-run version matching the version of oak-core you have and upload it to the server: wget

  2. Run this command to extract the list of datastore files from the segmentstore:

    java -Xmx6g -jar oak-run-*.jar dumpdatastorerefs [<segment_path>|<mongo_uri>] [dump_path]

    e.g. TarMK java -Xmx6g -jar oak-run-*.jar dumpdatastorerefs crx-quickstart/repository/segmentstore .

You can’t perform that action at this time.