felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Nodet" <gno...@gmail.com>
Subject Re: Framework error with ClassNotFoundException
Date Thu, 20 Dec 2007 15:29:32 GMT
I think the problem is in the R4SearchPolicyCore, line 345.
When the bundle can not be resolved, it throws a ClassNotFoundException.
I think it should rethrow the ResolveException, and the Felix#loadClass
method could catch it, fire the framework event and hide it by sending a
If there's no problem, I'll provide a patch asap.

On Dec 20, 2007 4:04 PM, Guillaume Nodet <gnodet@gmail.com> wrote:

> When a class can not be loaded, the o.a.f.framework.Felix class sends a
> framework event with an ERROR level.
> It can be very verbose in some cases: for example when using spring-osgi,
> for each spring bean defined, spring tries to load a class names
> XxxBeanInfo, where Xxx is the implemenation class name of the loaded spring
> bean.
> The piece of code is the loadBundleClass method, lines 1452 of the Felix
> class:
>     protected Class loadBundleClass(FelixBundle bundle, String name)
> throws ClassNotFoundException
>     {
>         Class clazz = bundle.getInfo().getCurrentModule().getClass(name);
>         if (clazz == null)
>         {
>             // Throw exception.
>             ClassNotFoundException ex = new ClassNotFoundException(name);
>             // The spec says we must fire a framework error.
>             fireFrameworkEvent(
>                 FrameworkEvent.ERROR, bundle,
>                 new BundleException(ex.getMessage()));
>             throw ex;
>         }
>         return clazz;
>     }
> Given the comment, I've tried to find what the spec says.  I think the
> comment refers to the Bundle.loadClass methods.  Quoting the spec:
> If this bundle cannot be resolved, a Framework event of type Frame-
> workEvent.ERROR is fired containing a BundleException with details of the
> reason this bundle could not be resolved. This method must then throw a
> ClassNotFoundException.
> My understanding is that the framework event must be fired when the bundle
> can not be *resolved*, not each time a class can not be found.  I suppose
> such a case could only happen if the bundle has been installed but not yet
> resolved and someone is using the loadClass method.  Can someone please
> share thoughts on this ?
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/

Guillaume Nodet
Blog: http://gnodet.blogspot.com/

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message