Finding SNS nodes

Find same name sibling(SNS) nodes

Before Jackrabbit Oak, it was possible to create same name sibling nodes(SNS) in CRX 2.

However, to upgrade to CRX 3 Oak, those nodes need to be removed.

To find those nodes, use the Groovy script below in Felix script console.

Once installed, the script console is available at /system/console/scriptconsole.

Don't forget to install the Groovy bundle after installing Script console.

The script logs the SNS nodes paths in a logger named sns that you need to create in the OSGI console.

properties of sns logger:"{5}""sns"]"logs/sns.log""debug"

Groovy script

def traverseAndLogSNS(node, session, log){
	if(node.index != 1) {
	if(node.hasNodes()) {
		def ni = node.nodes
			traverseAndLogSNS(ni.nextNode(), session, log)

def repo = osgi.getService(
def session = repo.loginAdministrative(null)
def root = session.getRootNode()
def log = org.slf4j.LoggerFactory.getLogger("sns")

traverseAndLogSNS(root, session, log)


The script can be esily adapted to log only sns nodes under a certain path.