Resource resolver closing in doTag method | Community
Skip to main content
May 14, 2018
Solved

Resource resolver closing in doTag method

  • May 14, 2018
  • 2 replies
  • 2381 views

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.
Best answer by joerghoh

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

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
May 14, 2018

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

tulasi21Author
May 15, 2018

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.