Event Handler Path property is throwing null | Community
Skip to main content
August 19, 2022

Event Handler Path property is throwing null

  • August 19, 2022
  • 1 reply
  • 1670 views

Can you please to solve the null pointer exception in the handle event method.
Environment: AEMASCS

Below is the sample code which will execute when the content is published in this path(/content/dam).
paths is throwing the null pointer exception.

SlingConstants.PROPERTY_PATH = path
@Component(immediate = true, service = EventHandler.class, property = {
Constants.SERVICE_DESCRIPTION + "= This event handler listens the events on page activation",
EventConstants.EVENT_TOPIC + "=org/apache/sling/distribution/agent/package/distributed",
EventConstants.EVENT_FILTER + "=(&(distribution.paths=/content/dam/*) (|(distribution.type=ADD)(distribution.type=DELETE)))",
})
public class TestHandler implements EventHandler {
public void handleEvent(Event event) {
log.info("Testing on DEV...");
String[] paths = (String[]) event.getProperty(SlingConstants.PROPERTY_PATH);
}

Please help me.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Jagadeesh_Prakash
Community Advisor
Community Advisor
August 19, 2022

@nishma  I tried the same scenario in AEMaaCS and it worked for us. Please refer to below code snippet

 

@Component(immediate = true, property = { "event.topics=org/apache/sling/distribution/importer/package/imported",
"event.filter=(|(distribution.type=ADD)(distribution.type=DELETE))" })
public class AkamaiSlingDistributionEventHandler implements EventHandler {
public static final String DISTRIBUTION_PATHS = "distribution.paths";

@Override
public void handleEvent(Event event) {
if (event.getProperty(DISTRIBUTION_PATHS) != null) {
String[] pagePath = (String[]) event.getProperty(DISTRIBUTION_PATHS);
}
}

 

NishmaAuthor
August 21, 2022

@jagadeesh_prakash Thanks for the response. Just want to check how you validated in your local server. since it will trigger when content distribution is configured. I'm unable to configure in the local server.

Jagadeesh_Prakash
Community Advisor
Community Advisor
August 22, 2022

@nishma There is no special configurations needed to do in local to test it. It should get triggered when ever there is any page or asset replication is done. 

 

Or you can test in cloud dev environment as well