Expand my Community achievements bar.

SOLVED

JCR event listener is not working in aem 6.4

Avatar

Level 4

Hi all,

Looks like the JCR event listener in 6.4 is broken. Events dont get triggered at all. Is anyone else facing the same issue? Is there any solution?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi Scott,

It does work with system user as well. But you need JCR repository session in order to get jcr events work.

Below code works for me.

aem63app-repo/SampleJCREvent.java at master · arunpatidar02/aem63app-repo · GitHub

@Reference
private SlingRepository repository;
private Session session;
private ObservationManager observationManager;
protected void activate(ComponentContext context) throws Exception {
session = repository.loginService("readService",null);
observationManager = session.getWorkspace().getObservationManager();
observationManager.addEventListener(this, Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED, "/content/AEM64App/fr", true, null,
new String[]{"cq:PageContent","nt:unstructured"} , true);
logger.info("*************added JCR event listener");
}


Arun Patidar

View solution in original post

22 Replies

Avatar

Community Advisor

Then it should work

Do you have service user and other user mapping configuration for below

 

session = repository.loginService("readService",null); 

 



Arun Patidar

Avatar

Level 4

@arunpatidar, Yes, I have. but event is not triggering. is there anything i need to verify?