Modifying Classpath at Runtime

Java - No Comments » - Posted on August, 27 at 4:19 pm

A hackish way of modifying the classpath at runtime can be done in a way described at the java forums Modifying Classpath at Runtime
A cleaner approach is to configure your own classloader and set it as the threads context classloader

URL[] urls=new URL[2];

URLClassLoader classLoader=new URLClassLoader(urls);

Thread.currentThread().setContextClassLoader(classLoader);

This is extremely useful if your unit test cases have dependencies [...]

Read More..>>

Posted in Java | No Comments »

InheritableThreadLocal and Tomcat

Java - No Comments » - Posted on May, 8 at 1:18 am

InheritableThreadLocal does not work with tomcat as tomcat thread pool does not clear the thread local contacts after a request has been executed. This results in no good way to share information information between the parent and the child threads that are created using thread local variables.
One way to solve this problem is to [...]

Read More..>>

Posted in Java | No Comments »