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

AEM 6.5.12 unclosed session debugging

Avatar

Level 9

Hi all,

Is there a better way to debug unclosed resource resolver or session objects ? 
i could look at JMX and sessionstatistics and perhaps session count but is there a way to identify for an object there what created it and are there unclosed session objects or resource resolvers? 
i see nothing in init stack trace and logs alone is being of help where I am looking for a trace of my class to check for unclosed resource resolver at the moment 

 

Please let me know better ways 

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi @NitroHazeDev ,

Since the 'system/console/status-Threads' has snapshot of all the threads so it is helpful in getting the thread info and their status. 

Also, JMX can provide information about the sessions that are currently open and the resource resolvers that are currently in use. However, it is not possible in my opinion to determine the specific class that created a session or resource resolver using JMX. Try following these steps:

  1. Open JConsole and connect to the AEM instance.
  2. In the MBeans tab, expand the com.day.crx.core node.
  3. Under the com.day.crx.core node, you will find MBeans for resource resolvers and sessions.
  4. Select the MBean for resource resolvers or sessions and view the attributes and operations in the Attributes and Operations tabs.

 

You might need to register the com.day.crx.core MBean to enable the JMX remote connector in the AEM instance. To do this, you will need to add the following configuration to the AEM instance's start script: 

-Dcom.sun.management.jmxremote.port=<port> \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false

 

Note: The above configuration will disable SSL and authentication for the JMX remote connector. This is not recommended for production environments. 

 

Let me know how you go.

 

Thanks,

Monendra

 

View solution in original post

7 Replies

Avatar

Level 5

if you have personally guaranteed that all your code is wrapped around with the JAVA 7 resource block, checked all sessionstatistics, etc... The next thing you can do is just deploy the code, and wait for a couple of days to get Adobe's looking glass report. From there they can determine what else you might have missed.

Avatar

Level 9

Anything other than looking glass? Like jmx  etc ? How do you check with session stats is the question for the specific session you create 

Avatar

Level 4

Hi @NitroHazeDev 

Here are a few approaches you can explore to debug unclosed resource resolver or session objects in AEM:

  1. Use the AEM JMX console: The AEM JMX console provides a number of metrics and attributes that can be useful for debugging resource resolver and session objects. For example, you can use the SessionStatistics MBean to view the number of active sessions, the number of closed sessions, and the number of sessions that have timed out. You can also use the SlingRepositoryStatistics MBean to view the number of active resource resolvers and the number of closed resource resolvers.

  2. Use the AEM Health Check service: The AEM Health Check service provides a set of checks that can help identify potential issues with resource resolvers and sessions. You can use the SessionCheck and ResourceResolverCheck checks to view the number of active and closed resource resolvers and sessions, and to detect potential leaks.

  3. Use the AEM Logging service: The AEM Logging service can be useful for debugging resource resolver and session objects because it provides detailed logging information about the creation and closure of these objects. You can use the com.day.crx.core.Session and com.day.crx.core.ResourceResolver loggers to view the stack traces of the methods that create and close resource resolvers and sessions.

  4. Use a code profiler: A code profiler is a tool that can help identify potential issues with resource resolver and session objects by analyzing the performance of your code. 

By using one or more of these approaches, you should be able to identify and debug unclosed resource resolver and session objects in AEM.

 

Thanks,

Monendra

 
 
 

Avatar

Level 9

Thanks @Monendra_Singh 

For #1- is there a way to know which is open and which is closed and what is the class or stacktrace? A lil bit more detail will help 

I for instance have a sling model and I get the resource resolver by using @inject or I can get by resource.getResourceResolver . I sent it to another service class but don’t think it’s right since passing it might mean it is out of scope and I might need to open it again in the service using try resource block with a service user.

debugging this would help . I see no errors in console but want to be sure 

 

#2 - where can I find it and how do I detect leaks more details or snapshots would help 

 

#3- do we set them at info level and do they provide details as to which class is causing the issue with sessions 

Are they valid packages could not find them on 6.5.12.. com.day.crx

 

#4 - any example used ?

 

 

Avatar

Level 4

Hey mate,

JMX console in AEM:

SessionStatistics

Monendra_Singh_2-1672373016584.png

 

 

When you go to Tools -> Operations -> Monitoring. You get an option to create heaps of monitoring options including 'no of active sessions'.

Monendra_Singh_0-1672372452330.png

Here you can create your own custom monitoring based on the available JMX beans.

Monendra_Singh_1-1672372548743.png

 

You can get session count in JMX as well.

Monendra_Singh_3-1672373139702.png

 

Also, You can connect amd monitor it using jconsole, here is the screenshot of my local machine

Monendra_Singh_4-1672374523308.png

You can go to mbean section and explore if you get what you want as you have lots of information available there. Do let me know how you go.

Thanks,

Monendra

 

Avatar

Level 9

Thanks @Monendra_Singh , i am doing the same, but wondering if it tells me clearly what specific class created the session for instance.

Is that something that JMX can tell me ? i tried picking the id from the sessionstats repo reader and went to /system/console/status-Threads, is this the  way?


  Thread #2102/Thread-1827 [priority=1, alive=true, daemon=true, interrupted=false, loader=java.net.URLClassLoader@4130a648]

I tried the packages, couldn't find it autopopulated for resource resolver unclosed sessions debug

Avatar

Correct answer by
Employee

Hi @NitroHazeDev ,

Since the 'system/console/status-Threads' has snapshot of all the threads so it is helpful in getting the thread info and their status. 

Also, JMX can provide information about the sessions that are currently open and the resource resolvers that are currently in use. However, it is not possible in my opinion to determine the specific class that created a session or resource resolver using JMX. Try following these steps:

  1. Open JConsole and connect to the AEM instance.
  2. In the MBeans tab, expand the com.day.crx.core node.
  3. Under the com.day.crx.core node, you will find MBeans for resource resolvers and sessions.
  4. Select the MBean for resource resolvers or sessions and view the attributes and operations in the Attributes and Operations tabs.

 

You might need to register the com.day.crx.core MBean to enable the JMX remote connector in the AEM instance. To do this, you will need to add the following configuration to the AEM instance's start script: 

-Dcom.sun.management.jmxremote.port=<port> \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false

 

Note: The above configuration will disable SSL and authentication for the JMX remote connector. This is not recommended for production environments. 

 

Let me know how you go.

 

Thanks,

Monendra