Java use-class getting called twice

bilala23933647

05-05-2020

Dear members,

 

I'm using AEM 6.4.4 and using wcm-use along with it. The issue is that my use-class activate() method is getting called twice. Anyone has faced this issue before? I tried debugging it but no luck how it's happening. Any help would be really appreciated.

 

Thanks,

Bilal.

View Entire Topic

Theo_Pendle

MVP

09-05-2020

Hi @bilala23933647,

My first input for this is probably not the answer you're looking for, but... you should think about switching from WCMUse to Sling Models. They allow for more features, are easier to use and are the current best practice for AEM component models. They are better documented and these days I think most people are more used to Sling Models so you're likely to get more and better answers if you ask a question 😉 This would be a good candidate for an upgrade, you may find that it solves your problem!

However, sticking to WCMUse for now:

  1. If your activate() method is being called twice, the most likely reason is that there are two requests being made. How are you making the request to the model? For example, if you have a test page with a bunch of components on it and you are loading that page to test, is it possible that there are 2 components that use the CommonUtilUse model and therefore it is being called twice?
  2. Are you using CommonUtilUse.java anywhere in your Java code (even if you are not directly calling activate())? Becuase activate() is called automatically in some scenarios, so perhaps you are indirectly calling it via your SuperScriptUse.java class or something along those lines?