Return-Path: Delivered-To: apmail-felix-dev-archive@www.apache.org Received: (qmail 72630 invoked from network); 23 Aug 2007 09:35:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Aug 2007 09:35:41 -0000 Received: (qmail 8391 invoked by uid 500); 23 Aug 2007 09:35:38 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 8351 invoked by uid 500); 23 Aug 2007 09:35:38 -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 8342 invoked by uid 99); 23 Aug 2007 09:35:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2007 02:35:38 -0700 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 (athena.apache.org: domain of rajinisivaram@googlemail.com designates 64.233.166.182 as permitted sender) Received: from [64.233.166.182] (HELO py-out-1112.google.com) (64.233.166.182) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2007 09:35:32 +0000 Received: by py-out-1112.google.com with SMTP id a25so828972pyi for ; Thu, 23 Aug 2007 02:35:10 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=kS4vT5B9J541ssm9o0F+i8wHVEkqcyz9MnYOFd4epDkAq2JspK+DYoI8v9VJZjhk+vU2NyxhwekpB7bsU7Td5ciFZXm8S2APZNefFftNhkkRmZmq5smPyoOKqMCigOKbDnixE3vFRxxswaNL1kjmvGE3BguZS6LEdtKbhx4UsnM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=sZR0DnT++Cfr1mjrnfbywx5GEP5jTgVonwfxSOOcY/y3DLBQSCP9mK45h3ZMOi/Ab/09sjLKRlTI4n3S61rjDLsURsCwe2/rY2gY7+AYkENjs3G7PafS3CBrkoT1+n23Kp8kpLNTMfDNB0COLQEdXllCE4sDo1eAXorENxK3Bcw= Received: by 10.65.250.11 with SMTP id c11mr2860913qbs.1187861710201; Thu, 23 Aug 2007 02:35:10 -0700 (PDT) Received: by 10.64.195.19 with HTTP; Thu, 23 Aug 2007 02:35:10 -0700 (PDT) Message-ID: Date: Thu, 23 Aug 2007 10:35:10 +0100 From: "Rajini Sivaram" To: dev@felix.apache.org Subject: Re: Intermittent exception during Felix shutdown In-Reply-To: <1187797285.20535.58.camel@bslm-046.corp.day.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_95168_6554794.1187861710148" References: <1187797285.20535.58.camel@bslm-046.corp.day.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_95168_6554794.1187861710148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Felix, Would it be possible for you to send me a jar file containing the fix? I dont have a source build at the moment, so it will be easier for me if you could send me the jar. My understanding (I may be totally wrong) was that that during Felix shutdown, all the bundles were being stopped causing all the services from the bundles to be unregistered. When one of the services got unregistered, a component (ComponentA) which had a reference to this service is reactivated (Stack trace 1). This causes the ComponentActorThread to call deactivateInternal for ComponentA (Stack trace 2) resulting in its services being unregistered. Meanwhile the thread doing the shutdown continues to stop all bundles including the bundle which contains ComponentA, unregistering services from ComponentA in a different thread (Stack trace 3). Stack trace 1 and 3 are from the same thread and 1 preceeds 3. Stack trace 2 and 3 are on different threads and can occur simultaneously causing an exception. *Stack trace 1:* Thread [FelixStartLevel] (Suspended (breakpoint at line 711 in DependencyManager)) DependencyManager.removedService(ServiceReference) line: 711 DependencyManager.serviceChanged(ServiceEvent) line: 109 EventDispatcher.invokeServiceListenerCallback(Bundle, EventListener, Filter, Object, EventObject) line: 735 EventDispatcher.fireEventImmediately(Logger, int, Object[], EventObject) line: 593 EventDispatcher.fireServiceEvent(ServiceEvent) line: 525 Felix.fireServiceEvent(ServiceEvent) line: 3510 Felix.access$000(Felix, ServiceEvent) line: 36 Felix$1.serviceChanged(ServiceEvent) line: 576 ServiceRegistry.fireServiceChanged(ServiceEvent) line: 435 ServiceRegistry.unregisterService(Bundle, ServiceRegistration) line: 86 ServiceRegistrationImpl.unregister() line: 99 ImmediateComponentManager(AbstractComponentManager).unregisterComponentService() line: 503 ImmediateComponentManager(AbstractComponentManager).deactivateInternal() line: 369 ImmediateComponentManager(AbstractComponentManager).disableInternal() line: 390 ImmediateComponentManager(AbstractComponentManager).disposeInternal() line: 419 ImmediateComponentManager(AbstractComponentManager).dispose() line: 224 BundleComponentActivator.dispose() line: 229 Activator.disposeComponents(Bundle) line: 230 Activator.bundleChanged(BundleEvent) line: 161 EventDispatcher.invokeBundleListenerCallback(Bundle, EventListener, EventObject) line: 660 EventDispatcher.fireEventImmediately(Logger, int, Object[], EventObject) line: 589 EventDispatcher.fireBundleEvent(BundleEvent) line: 503 Felix.fireBundleEvent(int, Bundle) line: 3499 Felix._stopBundle(FelixBundle, boolean) line: 1901 Felix.stopBundle(FelixBundle, boolean) line: 1866 Felix.setFrameworkStartLevel(int) line: 1080 StartLevelImpl.run() line: 258 Thread.run() line: 803 *Stack trace 2:* Thread [SCR Component Actor] (Suspended (breakpoint at line 99 in ServiceRegistrationImpl)) ServiceRegistrationImpl.unregister() line: 99 ImmediateComponentManager(AbstractComponentManager).unregisterComponentService() line: 503 ImmediateComponentManager(AbstractComponentManager).deactivateInternal() line: 369 AbstractComponentManager.access$200(AbstractComponentManager) line: 55 AbstractComponentManager$3.run() line: 176 ComponentActorThread.run() line: 81 *Stack trace 3:* Thread [FelixStartLevel] (Suspended (breakpoint at line 99 in ServiceRegistrationImpl)) ServiceRegistrationImpl.unregister() line: 99 ServiceRegistry.unregisterServices(Bundle) line: 119 Felix._stopBundle(FelixBundle, boolean) line: 1946 Felix.stopBundle(FelixBundle, boolean) line: 1866 Felix.setFrameworkStartLevel(int) line: 1080 StartLevelImpl.run() line: 258 Thread.run() line: 803 Thank you... Regards, Rajini On 8/22/07, Felix Meschberger wrote: > > Hi Rajini, > > I have to admit, that I am not 100% sure, what is going on. But this is > what I suppose: > > Some component has to be activated resulting thus (probably) calling the > ImmediateComponentManager.createObjectInstance method (most probably > asynchronously). Most probably this fails and results in the > AbstractComponentManager.deactivate() method being called. This method > (asynchronously again, but actually queued, so definitively later) tries > to unregister a service which may or may not be registered... > > At the "same time" (whatever that means :-) ) the Bundle containing the > component is being stopped (probably due to framework shutdown, doesn't > matter, actually) and the framework has already unregistered the > service. > > The problem here is, that the createObjectInstance method should not > call the deactivate method for asynchronous deactivation. In fact, no > real deactivation is needed anyway, so I rewrote that part of the > implementation. > > I will test this code with my tests further. Could you also test your > testcase again ? Thanks. I did not deploy a new snapshot yet, so you > will have to build it yourself. If this is not possible for you, please > let me know. > > Regards > Felix > > Am Montag, den 20.08.2007, 15:18 +0100 schrieb Rajini Sivaram: > > Hello, > > > > One of my testcases intermittently throws an exception during shutdown. > I > > have managed to recreate the exception under a debugger, and it shows > two > > threads trying to unregister the same service. The test fails only when > > declarative services are used. I am using Felix 1.0.0. The test uses > > multiple versions of a bundle, but I am not sure if that has anything to > do > > with the exception. > > > > The exception thrown is: > > > > --- Exception with component : Unexpected problem executing task --- > > java.lang.IllegalStateException: Service already unregistered. > > at org.apache.felix.framework.ServiceRegistrationImpl.unregister > ( > > ServiceRegistrationImpl.java:105) > > at > > org.apache.felix.scr.AbstractComponentManager.unregisterComponentService > ( > > AbstractComponentManager.java:503) > > at > org.apache.felix.scr.AbstractComponentManager.deactivateInternal( > > AbstractComponentManager.java:369) > > at org.apache.felix.scr.AbstractComponentManager.access$200( > > AbstractComponentManager.java:55) > > at org.apache.felix.scr.AbstractComponentManager$3.run( > > AbstractComponentManager.java:176) > > at org.apache.felix.scr.ComponentActorThread.run( > > ComponentActorThread.java:81) > > > > Here is the stack trace of the two threads under the debugger (both are > > using the same object): > > > > Thread [FelixStartLevel] (Suspended (breakpoint at line > 97 > > in ServiceRegistrationImpl)) > > ServiceRegistrationImpl.unregister() line: 97 > > ServiceRegistry.unregisterServices(Bundle) line: > 119 > > Felix._stopBundle(FelixBundle, boolean) line: > 1946 > > Felix.stopBundle(FelixBundle, boolean) line: > 1866 > > Felix.setFrameworkStartLevel(int) line: 1080 > > StartLevelImpl.run() line: 258 > > Thread.run() line: 803 > > Thread [SCR Component Actor] (Suspended (breakpoint at > line > > 97 in ServiceRegistrationImpl)) > > ServiceRegistrationImpl.unregister() line: 97 > > > > > ImmediateComponentManager(AbstractComponentManager).unregisterComponentService() > > line: 503 > > > > ImmediateComponentManager(AbstractComponentManager).deactivateInternal() > > line: 369 > > > > AbstractComponentManager.access$200(AbstractComponentManager) > > line: 55 > > AbstractComponentManager$3.run() line: 176 > > ComponentActorThread.run() line: 81 > > > > > > The exception thrown is the IllegalStateException from > > public void unregister() > > { > > if (m_svcObj != null) > > { > > m_registry.unregisterService(m_bundle, this); > > m_svcObj = null; > > m_factory = null; > > } > > else > > { > > * throw new IllegalStateException("Service already > > unregistered."); > > * } > > } > > > > > > > > Thank you... > > > > Regards, > > > > Rajini > > ------=_Part_95168_6554794.1187861710148--