felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Nodet" <gno...@gmail.com>
Subject Framework error with ClassNotFoundException
Date Thu, 20 Dec 2007 15:04:22 GMT
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
The piece of code is the loadBundleClass method, lines 1452 of the Felix

    protected Class loadBundleClass(FelixBundle bundle, String name) throws
        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.
                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

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 ?

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

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