Hi,
We are using felix framwork 3.0.4 and are having problems when one of our
bundle upgrades. We noticed the same issue also occurs if we uninstall, then
later re-install the bundle.
The bundle has an embedded dependency (e.g. a non-OSGi jar) that makes a call
to MessageDigest.getInstance("MD4"). When the bundle is first installed, This
internal call goes through without a problem. But after upgrading the bundle
or uninstalling and re-installing it, we start to get the following exceptions:
Caused by: java.security.NoSuchAlgorithmException: Error constructing
implementation (algorithm: MD4, provider: BC, class:
org.bouncycastle.jce.provider.JDKMessageDigest$MD4)
at java.security.Provider$Service.newInstance(Provider.java:1262)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
at java.security.Security.getImpl(Security.java:695)
at java.security.MessageDigest.getInstance(MessageDigest.java:159)
at rpc.security.ntlm.Responses.ntlmHash(Responses.java:186)
at rpc.security.ntlm.Responses.ntlmv2Hash(Responses.java:203)
at rpc.security.ntlm.Responses.getLMv2Response(Responses.java:102)
at
rpc.security.ntlm.NtlmAuthentication.createType3(NtlmAuthentication.java:270)
... 23 more
Caused by: java.lang.NullPointerException
at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1432)
at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.security.Provider$Service.getImplClass(Provider.java:1279)
at java.security.Provider$Service.newInstance(Provider.java:1237)
Using a debugger, we traced through this call and found that the
NullPointerException gets triggered when trying to load the
sun.reflect.ConstructorAccessorImpl class for creating a new instance of
org.bouncycastle.jce.provider.JDKMessageDigest$MD4. Note that the classloader
has no problems finding org.bouncycastle.jce.provider.JDKMessageDigest$MD4, it
only has an issue with sun.reflect.ConstructorAccessorImpl.
Stepping through the BundleWiringImpl calls, we noticed that the
NullPointerException occurs because the BundleWiringImpl instance has been
disposed (e.g. it is stale). The revision of the BundleWiringImpl confirms
this since it matches the revision of the original bundle install (when we
first start up the felix container). For example, the revision will be
something like [25] when the currently running bundle revision is actually
[25.2] or [27] (depending if we do upgrades or uninstall/re-install).
All the other non-sun classes required by the bundle go against the correct
version of BundleWiringImpl except for sun.reflect.ConstructorAccessorImpl.
Some how, no matter how many times we uninstall and re-install the bundle, the
sun.reflect.ConstructorAccessorImpl class always gets loaded by the same stale
instance of BundleWiringImpl (e.g. [25]). I imagine there must be some sort of
caching going on somewhere that is keeping a reference to this old classloader,
but I don't understand where or how.
Note that we are able to avoid this issue if we set:
org.osgi.framework.bootdelegation=sun.*
Note that just setting 'sun.reflect.*' does not work. We tried using dynamic
imports for all sun packages, but this did not work:
<DynamicImport-Package>sun.*</DynamicImport-Package>
Unfortunately we can not easily restart the Felix container to set the boot
delegation property. Is there a way to avoid this class loading issue without
requiring a restart of Felix?
-Karl
This electronic message contains information which may be confidential or
privileged. The information is intended for the use of the individual or entity
named above. If you are not the intended recipient, be aware that any
disclosure, copying, distribution or use of the contents of this information is
prohibited. If you have received this electronic transmission in error, please
notify us by e-mail at ([email protected]) immediately.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]