Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

wim_van_den_bra
Level 2
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
Jörg_Hoh
Correct answer by
Employee
Employee

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

View solution in original post

2 Replies
smacdonald2008
Level 10
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. 

Jörg_Hoh
Correct answer by
Employee
Employee

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

View solution in original post