Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Resource resolver closing in doTag method

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

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

Avatar

Level 4

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.