Page throws NullPointerException upon activation in AEM sites

Last update: 2022-09-27

Description

Issue
When a page is activated in AEM, the activation fails with the following exception:

javax.servlet.ServletException: java.lang.NullPointerException
at com.day.cq.wcm.core.impl.reference.ActivationReferenceSearchServlet.doGet(ActivationReferenceSearchServlet.java:175)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService(SlingSafeMethodsServlet.java:269)

Environment
AEM 6.x

Cause
One of the images referenced by the page had an issue with its properties.

The image causing issues was missing the cq:lastReplicated property while it had the cq:lastReplicatedBy and cq:lastReplicationAction properties.

Specified Messages

javax.servlet.ServletException: java.lang.NullPointerException
at com.day.cq.wcm.core.impl.reference.ActivationReferenceSearchServlet.doGet
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService

Resolution

Resolution

  1. Identify all the images which have this conflict:

    SELECT * FROM dam:Asset AS parent INNER JOIN nt:base AS child ON ISCHILDNODE(child,parent) WHERE ISDESCENDANTNODE(parent, '/content/dam/journey/') AND child.cq:lastReplicated IS NULL AND child.cq:lastReplicatedBy IS NOT NULL
    
  2. Once the assets are identified, check if these assets were actually replicated or not.

  3. If Yes, add the property cq:lastReplicated with the type Date and copy the date from the publish server.

  4. In either case, you can remove the cq:lastReplicatedBy and cq:lastReplicatedAction properties, and activate the image again.

On this page