powered by Jive Software

Unstopped thread created while loading org.jivesoftware. smack.util.dns.JavaxResolver

HI,

We have integrated smack API in our tomcat web application. We used to login to openfire server and continues to login until tomcat process is shutdown.

But while stopping the tomcat process gracefully, we see one error line in catalina.out of our tomcat 7.

Below is the line :

SEVERE: The web application [/PluginWebappTest] appears to have started a thread named [Thread-2] but has failed to stop it. This is very likely to create a memory leak.

While analyzing the process using Jconsole , this thread** [Thread-2]** is having following information -

Name: Thread-2

State: RUNNABLE

Total blocked: 0 Total waited: 0

**Stack trace: **

** sun.net.dns.ResolverConfigurationImpl.notifyAddrChange0(Native Method)**

sun.net.dns.ResolverConfigurationImpl$AddressChangeListener.run(Unknown Source)

After debugging through smack3.3.0 code , we see like while loading class **“org.jivesoftware.smack.util.dns.JavaxResolver” in **SmackConfiguation.java - private static void parseClassToLoad(XmlPullParser parser) method , this thread got created and not stopped after that.

Please see like what is this thread got created as it is not allowing our tomcat process to stop gracefully.

Regards,

Keshav

Thanks for yor report. It is not 100% clear to me where the thread get’s created you are mentioning. As far as I can tell, Smack’s JavaxResolver is not related in any way to SmackConfiguration.parseClassToLoad(). An both do not create Threads.

Could you please post the full stack trace?

HI Flow,

I am looking into the code of smack 3.3.0 and this thread got created at line # 45 in JavaxResolver.java static block i.e. “dirContext = new InitialDirContext(env);”.

For stacktrace , when we call below statement ,

ConnectionConfiguration config = new ConnectionConfiguration(server, port);

It will create this thread as SmackConfiguration.java static block is called up and JavaxResover.java is initialized as its mentioned in META-INF/smack-config.xml file for the classes to load at startup.

Regards,

Keshav

If a new thread is caused by calling InitialDirContext’s constructor, then I am unable to locate the according code. But since this is part of the Java API, there is not much we could do on Smack’s side. I am also not sure how servere the error is, it’s hard to tell without finding the actual code that starts the thread.

Anyway, one option for you would be to switch to dnsjava, instead of doing DNS resolving with JavaX. But you also need to modify Smack so, that the static block of JavaxResolver is not called.