Expand my Community achievements bar.

SOLVED

JCR - EventListener - activate method not found - Adobe CQ 5.6.0

Avatar

Level 2

I'm trying to implement an EventListener to propagate some JCR changes (property changed, node added ...).

This topic has been discussed in a number of posts but different implementations are available and I'm inclined to describe the nitty gritty details on the required annotation as a very well kept secret.

SlingRepository is annotated without specific properties in following document:http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/04/event_handling_incq.html

and Component annotation has been set the following way:

@Component public class JCRListener implements EventListener{ }

With this flavor, I'm able to install my bundle from the Adobe CQ Web Console but my Active and Deactive methods are not triggered/invoked.

SlingRepository is annotated with specific properties (policy = ReferencePolicy.STATIC, cardinality = ReferenceCardinality.MANDATORY_UNARY) in following document:https://groups.google.com/forum/#!topicsearchin/day-communique/postEvent%7Csort:date%7Cspell:true/da...

and Component annotation has a specific setting

@Component(immediate=true) @Service public class JCRListener implements EventListener{ @Activate public void activate(ComponentContext componentContext){ .... } @Deactivate public void deactivate(ComponentContext componentContext){ .... } public void onEvent(EventIterator events) { .... } }

With this flavor, the deployment of my bundle fails and I'm getting the error[com.adobe.cq.JCRListener] activate method [activate] not found; Component will fail

I attache the complete code to facilitate investigation of the problem. Any help is very much appreciated, don't hesitate to let me know additional logging should be provided/enabled. 

Wim

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

I would make the activate and deactivate methods in protected scope, not public.

View solution in original post

2 Replies

Avatar

Level 10

A new community article on this subject will be published on April 18, 2014. I will update this thread once it is published. 

Avatar

Correct answer by
Employee Advisor

I would make the activate and deactivate methods in protected scope, not public.