0 Replies Latest reply on Oct 6, 2011 10:41 PM by 892965

    Threads Losing ClassLoader

      I've run afoul of an odd behavior with an application I've inherited. It runs a server-client set up using a third party network connection library. This library spins off a new thread to handle connections as needed. I've gone over the library code and that section is solid, it doesn't alter the threads at all, just creates new ones that are added to the same group. Once a connection terminates the thread utilized exits as well. At least one thread is always in existence though it is usually the last thread created. The process that starts the initial library thread (which in turn creates more as needed) is not a daemon and exits after starting up the library and some other services.

      The initial library thread is created with an inherited classloader (Launcher$AppClassLoader) and for the most part subsequent threads correctly inherit the same classloader. But for reasons I've yet to determine at seemingly random intervals, some of the threads end up with contextClassLoader == null. This can propagate into the entire pool of threads used for connections. Neither the library nor the application code invoke the setContextClassLoader method. The application code doesn't even interface with the threads at all. Any ideas what could be causing something like this to happen?