I am doing integration test but getting error in which i can't cast to implemented interface
IPOJO Component: @Component(immediate = true) @Provides public class MyComponent implements MyService { @Override public boolean islock() { return true; } } Following is test class extending KarafTestSupport @Test public void serviceCreationIsWorking() throws Exception { assertBundleInstalled("com.my.osgi.mycomponent"); MyService serviceObject = getOsgiService(MyService.class, 30000l); System.out.println("getOsgiService=" + serviceObject); System.out.println("getOsgiService method=" + serviceObject.islock()); assertConditions(5000, "No deadlock detected!", () -> serviceObject.islock() == true); } But on following line it throws error java.lang.ClassCastException: com.my.osgi.MyComponent cannot be cast to com.my.osgi.MyService MyService serviceObject = getOsgiService(MyService.class, 30000l); I googled and i found that /This can happen if two different classloaders load a class named <classname>. These two classes are then treated as entirely different classes, even if they have the same package and name (and even implementation/fields/methods). A common cause for this is if you use some kind of plugin system and both your base classes and the plugin classes provide the same class./ Any suggestion to resolve class loader issue?? -- Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html