Hi all, I am using the maven-surefire-plugin to run the testNG cases for my project. The test case calls an API internally that expects the current class loader to be a custom class loader. It does something like the following:
" CustomClassLoader customClassLoader = (CustomClassLoader) Thread.currentThread().getContextClassLoader();" My test case looks something like as follows: @Test public void testMethod { CustomClassLoader cl = new CustomClassLoader(); Thread.currentThread.setContextClassLoader(cl); ---call to the API } I set the class loader in my test case as shown above. However, I always hit a class cast exception in the API at the line mentioned above as follows: " Caused by: java.lang.ClassCastException: org.apache.maven.surefire.booter.Isolat edClassLoader " which means that the current loader is still the surefire's loader and not the CustomClassLoader. Am I doing something wrong or this is the way the plugin works?? Thanks for any help, Ravi. "Tough times never last, but tough men do..."