Skip to main content
Developer Jahia 8.2

What happens when a node that is referenced by other content is deleted?

Question

What happens when a node that is referenced by other content is deleted?

Answer

The deletion succeeds, and the reference is left dangling. Nothing blocks it and nothing cleans it up.

Measured on Jahia 8.2.3.2 - node B holds a weakreference to node A, then A is deleted:

Deleting Asucceeds - no referential integrity error
B still has the propertyyes
Reading its raw valuereturns A's uuid, unchanged
Resolving it to a nodethrows javax.jcr.ItemNotFoundException: <uuid>

Why it is not blocked

Jahia's content references are weak references. A JCR hard reference would refuse the delete with a referential integrity error; a weak reference carries no such guarantee by design, which is what allows editors to delete content without hunting down every page that points at it.

The cost is that the pointer survives its target.

What this means for your code

hasProperty returning true does not mean the reference resolves. This is the trap:

if (node.hasProperty("j:linknode")) {
    Node target = node.getProperty("j:linknode").getNode();   // may throw
}

Guard the resolution, not the existence:

if (node.hasProperty("j:linknode")) {
    try {
        Node target = node.getProperty("j:linknode").getNode();
        ...
    } catch (ItemNotFoundException e) {
        // the referenced content was deleted - render a fallback, skip, or log
    }
}

The same applies in a view: a JSP that walks a reference without a guard will produce a stack trace on a page that was fine yesterday, because the breakage happens in a different node's edit session than the one that renders.

Note the raw value is still readable with getString(), so you can log or report the missing uuid even when it no longer resolves - useful when auditing.

Finding them before your users do

Because nothing reports the breakage, a dangling reference is only discovered when something tries to resolve it. If reference integrity matters for a content type, the options are to check on publication with a rule, or to sweep periodically and report unresolvable references rather than waiting for a render to fail.


This article was drafted with AI assistance, then reviewed and curated by Jahia Customer Support engineers before publication.