Resource resolver closing in doTag method | Community
Skip to main content
Level 3
May 14, 2018 9:21 PM UTC
Solved

Resource resolver closing in doTag method

Hello.

I have a doTag() method where resource resolver is derived using:

     SlingHttpServletRequest request = (SlingHttpServletRequest) pageContext.getRequest();

             resRsolvr = request.getResourceResolver();

When am trying to close the resRsolvr object, My component never works.

May I know how to close this Object.

If am not closing this object am getting"Too many files open" in production.I

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
May 14, 2018 9:37 PM UTC

Hi,

At this occassion you don't open the resourceResolver, but you are just obtaining it; the resourceResolver has been opened by the Sling Engine, and the Sling Engine will also take care of closing it when all is done. Only close a resourceResolver if you have explicitly opened it (via the ResourceResolverFactory.login* methods).

The "too many open files" issue in your production environment has very likely a different root cause. Sling ResourceResolvers are not tied to files in the filesystem or network connections. The next time such a situation occurs in production, use a tool like "lsof" to list all open file of the AEM process, and then raise a Daycare ticket as well and provide this data to Adobe support.

Regarding lsof this page might help: https://www.howtoforge.com/linux-lsof-command/#-how-to-list-filesnbspspecific-to-a-process

Jörg

2 replies

tulasi21Author
Level 3
May 15, 2018 1:30 PM UTC

Thank you so much for the help. I was also thinking the same. We have a ticket with adobe, they closed saying custom code issues.

Now I will re-open it.

This was very helpful.

Thanks,

Tulasi.

Translate
joerghoh
joerghohAccepted solution
Employee
May 14, 2018 9:37 PM UTC

Hi,

At this occassion you don't open the resourceResolver, but you are just obtaining it; the resourceResolver has been opened by the Sling Engine, and the Sling Engine will also take care of closing it when all is done. Only close a resourceResolver if you have explicitly opened it (via the ResourceResolverFactory.login* methods).

The "too many open files" issue in your production environment has very likely a different root cause. Sling ResourceResolvers are not tied to files in the filesystem or network connections. The next time such a situation occurs in production, use a tool like "lsof" to list all open file of the AEM process, and then raise a Daycare ticket as well and provide this data to Adobe support.

Regarding lsof this page might help: https://www.howtoforge.com/linux-lsof-command/#-how-to-list-filesnbspspecific-to-a-process

Jörg

Translate