AEM 6.5 : Approach to avoid Cloud Manager AEM Rule for working listener implementation. | Community
Skip to main content
cquser1
Level 7
Jul 3, 2019 12:44 PM UTC

AEM 6.5 : Approach to avoid Cloud Manager AEM Rule for working listener implementation.

Hi All,

The error we are getting in CM is below

1] AEM-3[Non-thread safe object used as a field of Servlet/ Filter etc.]

Listener is working fine, but throwing above error for declaring session in our listener class which implements EventListener

private Session session ;

We are using this in activate() and deactivate() methods and looks like not possible to avoid the CM error.

2] Tried using Event Handler approach, wherein we want this to be invoked when page under certain path "/content/xxx" and few properties like "jcr:title"

are changed, the handler to be invoked for some custom processing.

Tried multiple things but no luck.

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/TestEventHandler.java  didnt work either.

3] Via ResourceChangeListener approach, resourceChange.getAddedPropertyNames()/resourceChange.getChangedPropertyNames(); are deprecated.

4] Is it possible to solve this issue with the above approaches mentioned?

5] If no to #4, Creating launchers/workflows is the only alternative to get this to work?

Any thoughts/pointers on this will be really helpful.

Arun Patidar​

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

8 replies

joerghoh
Employee
Jul 5, 2019 4:59 PM UTC

This is an programming error indicated by the integrated sonar checks.

A filter is a singleton, which can be run concurrently. Thus it must not have any non-static final members, because these would be shared among the invocations, and invocation A could overwrite the value of invocation B. Thus avoid any global member inside a filter. (For servlets the same limitations exists.)

Translate
cquser1
cquser1Author
Level 7
Jul 8, 2019 6:34 AM UTC

Hi Joerg,

Thank you for the information provided.

However, we are not very sure as to how to modify the code to avoid this CM rule check.

Arun Patidar​ Adding a finally block didn't help much. Any pointers/ thoughts on how this can be done will be helpful.

Translate
arunpatidar
New Participant
Jul 8, 2019 9:13 AM UTC

Hi,

According to adobe

The quality scanning process is not perfect and will sometimes incorrectly identify issues which are not actually problematic. This is referred to as a "false positive".

In these cases, the source code can be annotated with the standard Java @SuppressWarnings annotation specifying the rule ID as the annotation attribute.

Example

@SuppressWarnings("AEM Rules:AEM-3")

private Session adminSession;

Translate
Arun Patidar
cquser1
cquser1Author
Level 7
Jul 3, 2019 1:16 PM UTC

Just adding details : The listener implemented is on similar lines as done in Creating an Event Listener for Adobe Experience Manager 6.4.

To that implementation,  we are checking if eventIterator.nextEvent().getPath(); has the jcr:title and other properties and based on that we are adding our custom logic.

Translate
arunpatidar
New Participant
Jul 4, 2019 9:51 AM UTC

Hi,

I tried same code from Creating an Event Listener for Adobe Experience Manager 6.4  in 6.5 and I am not getting any exception.

Translate
Arun Patidar
cquser1
cquser1Author
Level 7
Jul 4, 2019 10:26 AM UTC

Hi Arun,

I mean the code in Creating an Event Listener for Adobe Experience Manager 6.4  is working fine but cloud manager is throwing AEM-3[Non-thread safe object used as a field of Servlet/ Filter etc.] while deployment to our servers, which probably we will not be able to fix.

So, we were exploring other ways[mentioned above] of resolving this issue and if there is a way out.

Translate