Return-Path: Delivered-To: apmail-felix-dev-archive@www.apache.org Received: (qmail 934 invoked from network); 20 Dec 2007 16:30:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Dec 2007 16:30:39 -0000 Received: (qmail 74914 invoked by uid 500); 20 Dec 2007 16:30:28 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 74878 invoked by uid 500); 20 Dec 2007 16:30:28 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 74869 invoked by uid 99); 20 Dec 2007 16:30:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Dec 2007 08:30:28 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gnodet@gmail.com designates 66.249.92.172 as permitted sender) Received: from [66.249.92.172] (HELO ug-out-1314.google.com) (66.249.92.172) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Dec 2007 16:30:17 +0000 Received: by ug-out-1314.google.com with SMTP id a2so642885ugf.13 for ; Thu, 20 Dec 2007 08:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=9B62FVzFDG7r+jM3xBRIufcz0LmRBAoaYgE9KxvLchA=; b=IKVYpcgvylynE8xv73UP1gBKl/ING86iaDp4WeTq39qVOtjsZmJT+BWjs0rTjUeyzSEmjjhmXWbJ0TN4xuyh4bzslfOJBuoH8jidCGK9eL9Nqw8u257TuHneYVQLHUdo48e3L1PL5lt6XV/LDkzyh3gux2Pv19xDiN9MmzVvwpc= 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=dU8uW488TreFNMh2DBD9jZ6GvvrJe0RnEgaG3JdHAWquO3DbE8YhAGeAXbLYyQT4p3hS13L+ZdG2CIQ0gXHx4hvQ4JxtTcmoS6EDz/jmE+01Dd7K2SUMhqlQefbYUFPRYnQghmHHZtSOesQVgV/Q7C3WSoHIQ5IDcQZZ2R8ps8M= Received: by 10.67.119.15 with SMTP id w15mr3624512ugm.73.1198168210013; Thu, 20 Dec 2007 08:30:10 -0800 (PST) Received: by 10.67.121.1 with HTTP; Thu, 20 Dec 2007 08:30:09 -0800 (PST) Message-ID: Date: Thu, 20 Dec 2007 17:30:09 +0100 From: "Guillaume Nodet" To: dev@felix.apache.org Subject: Re: Framework error with ClassNotFoundException In-Reply-To: <476A9260.6000403@ungoverned.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1634_6772296.1198168209999" References: <476A9260.6000403@ungoverned.org> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_1634_6772296.1198168209999 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I've raised a JIRA and attached a patch: https://issues.apache.org/jira/browse/FELIX-441 On Dec 20, 2007 5:03 PM, Richard S. Hall wrote: > Guillaume Nodet wrote: > > 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 > > ClassNotFoundException. > > If there's no problem, I'll provide a patch asap. > > > > No, that won't work for the reason stated in the comment in the search > policy. Further, ResolveException is a checked exception created in the > searchpolicy package, which is a specific implementation of a search > policy for the module layer. The module layer doesn't know about > ResolveExceptions and thus IModule.getClass() does not throw such an > exception. > > I guess the proper way to achieve what you want would be for > loadBundleClass() to try to resolve the bundle before calling > IModule.getClass(), that way it can catch the resolve exception and only > report the error if necessary. > > -> richard > > > > > On Dec 20, 2007 4:04 PM, Guillaume Nodet 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/ > >> > > > > > > > > > > > -- Cheers, Guillaume Nodet ------------------------ Blog: http://gnodet.blogspot.com/ ------=_Part_1634_6772296.1198168209999--