[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [equinox-dev] java.lang.NoClassDefFoundError: sun/reflect/ReflectionFactory
- From: "Stuart McCulloch" <mcculls@xxxxxxxxx>
- Date: Tue, 8 Jul 2008 01:39:51 +0800
- Delivered-to: firstname.lastname@example.org
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=HX4Jnuq7BEYDeVw2XOlZ3i/lIk2WQF/f8GYOAWlXfg662PNNgLRwCSLdsoFNOav5Iw qiaiYa2u158oKEG5nZXQ/RB48trXAFb2iMo1NMNv6m6PVBW7kzfxze3a6MYK4cwQYqsW q4aQoBPfgweivB9bhZ8lG2JipSBF/VCeV+x4k=
2008/7/7 Nikhil Sharma <niksharma@xxxxxxxxx>:
When i try to use -
final ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
in a bundle it throws a -
What might be the reason for this.
do you import the "sun.reflect" package in your bundle manifest?
this is a simplification, but basically the packages that a bundle can see are:
1) those listed under the "org.osgi.framework.bootdelegation" property AND available from the framework's bootclasspath
2) those contained inside the bundle
3) those imported via Import-Package (or DynamicImport-Package) AND exported from another bundle with matching constraints (versions, attributes, etc.)
4) those visible from another bundle via Require-Bundle
but I strongly recommend you read the OSGi spec as it has a much clearer
(and definitive) description of package visibility in OSGi, along with pictures!
typically the "org.osgi.framework.bootdelegation" property defaults to "java.*"
so if you don't import the "sun.reflect" package, or no other bundle exports it,
then you will see a NCDF error.
if the system bundle (usually bundle 0) exports "sun.reflect" then you just need
to add this package to your Import-Package in the manifest - otherwise you can
try adding it to the bootdelegation list, though this is less flexible because your
bundle then depends on this property being set correctly
as a side note, it is bad practice to depend on "sun.*" packages as these are
private Sun implementation classes, and are not part of the public Java API.
these classes may change or disappear between Java releases depending on
how Sun feels - and may not be available on non-Sun implementations of Java.
equinox-dev mailing list