Saturday, 15 February 2014

java - OSGi Classloader not finding a class and not letting me include it -



java - OSGi Classloader not finding a class and not letting me include it -

i writing plugin third-party osgi container. plugin has code looks this:

resource r=factory.getinstance().getresource("test"); string s=r.getlist()[0];

it fails on sec line this:

caused by: java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.eclipse.equinox.internal.ds.model.servicecomponent.activate(servicecomponent.java:206) ... 34 more caused by: java.lang.noclassdeffounderror: com/thirdparty/list @ user1.samplecode.main(samplecode.java:20) ... 39 more caused by: java.lang.classnotfoundexception: com.thirdparty.list @ org.eclipse.osgi.internal.loader.bundleloader.findclassinternal(bundleloader.java:489) @ org.eclipse.osgi.internal.loader.bundleloader.findclass(bundleloader.java:405) @ org.eclipse.osgi.internal.loader.bundleloader.findclass(bundleloader.java:393) @ org.eclipse.osgi.internal.baseadaptor.defaultclassloader.loadclass(defaultclassloader.java:105) @ java.lang.classloader.loadclass(classloader.java:247) ... 42 more

then, when seek include missing class plugin jar, different error:

caused by: java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.eclipse.equinox.internal.ds.model.servicecomponent.activate(servicecomponent.java:206) ... 34 more caused by: java.lang.linkageerror: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/defaultclassloader) initiated loading different type name "com/thirdparty/list" @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclasscond(classloader.java:631) @ java.lang.classloader.defineclass(classloader.java:615) @ org.eclipse.osgi.internal.baseadaptor.defaultclassloader.defineclass(defaultclassloader.java:183) @ org.eclipse.osgi.baseadaptor.loader.classpathmanager.defineclass(classpathmanager.java:576) @ org.eclipse.osgi.baseadaptor.loader.classpathmanager.findclassimpl(classpathmanager.java:546) @ org.eclipse.osgi.baseadaptor.loader.classpathmanager.findlocalclassimpl(classpathmanager.java:477) @ org.eclipse.osgi.baseadaptor.loader.classpathmanager.findlocalclass_lockclassloader(classpathmanager.java:465) @ org.eclipse.osgi.baseadaptor.loader.classpathmanager.findlocalclass(classpathmanager.java:445) @ org.eclipse.osgi.internal.baseadaptor.defaultclassloader.findlocalclass(defaultclassloader.java:211) @ org.eclipse.osgi.internal.loader.bundleloader.findlocalclass(bundleloader.java:376) @ org.eclipse.osgi.internal.loader.bundleloader.findclassinternal(bundleloader.java:452) @ org.eclipse.osgi.internal.loader.bundleloader.findclass(bundleloader.java:405) @ org.eclipse.osgi.internal.loader.bundleloader.findclass(bundleloader.java:393) @ org.eclipse.osgi.internal.baseadaptor.defaultclassloader.loadclass(defaultclassloader.java:105) @ java.lang.classloader.loadclass(classloader.java:247) @ user1.samplecode.main(samplecode.java:20) ... 39 more

what going on? appears classloader knows class need , won't allow me utilize or include own re-create of it.

java osgi classloader

No comments:

Post a Comment