Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1FA23106B1 for ; Wed, 14 Aug 2013 16:09:54 +0000 (UTC) Received: (qmail 40590 invoked by uid 500); 14 Aug 2013 16:09:50 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 40429 invoked by uid 500); 14 Aug 2013 16:09:49 -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 40401 invoked by uid 99); 14 Aug 2013 16:09:48 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Aug 2013 16:09:48 +0000 Date: Wed, 14 Aug 2013 16:09:47 +0000 (UTC) From: "J.W. Janssen (JIRA)" To: dev@felix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FELIX-3846) Felix + Felix HTTP Jetty causes IllegalStateException during start up MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FELIX-3846?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13739814#comment-13739814 ] J.W. Janssen commented on FELIX-3846: ------------------------------------- I'm not sure that the proposed fix is even necessary with the upgrade to Jetty 7. I am able to reproduce the problem with Jetty 6, but never with Jetty 7. Can somebody confirm this? > Felix + Felix HTTP Jetty causes IllegalStateException during start up > --------------------------------------------------------------------- > > Key: FELIX-3846 > URL: https://issues.apache.org/jira/browse/FELIX-3846 > Project: Felix > Issue Type: Bug > Components: Framework, HTTP Service > Affects Versions: framework-4.0.3, http-2.2.0 > Environment: Java version: 1.6.0_37, vendor: Apple Inc. > All operating systems > Reporter: Ronald Chen > Attachments: felix-http-jetty-2.2.0-fix-illegal-state-exception.patch > > > There is a race condition during the activation of the felix http jetty bundle when used within a felix container. > During the activation of the felix http jetty bundle you will intermittently see: > java.lang.IllegalStateException: Can only register services while bundle is active or activating. > at org.apache.felix.framework.Felix.registerService(Felix.java:3209) ~[na:na] > at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346) ~[na:na] > at org.apache.felix.http.base.internal.HttpServiceController.register(HttpServiceController.java:135) ~[org.apache.felix.http.jetty_2.2.0.jar:na] > at org.apache.felix.http.base.internal.DispatcherServlet.init(DispatcherServlet.java:48) ~[org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.jetty.Server.doStart(Server.java:224) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.apache.felix.http.jetty.internal.JettyService.initializeJetty(JettyService.java:164) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.apache.felix.http.jetty.internal.JettyService.startJetty(JettyService.java:115) [org.apache.felix.http.jetty_2.2.0.jar:na] > at org.apache.felix.http.jetty.internal.JettyService.run(JettyService.java:290) [org.apache.felix.http.jetty_2.2.0.jar:na] > at java.lang.Thread.run(Thread.java:680) [na:1.6.0_37] > I debugged into line Felix.java:3209 and discovered the cause by is thrown by Felix.java:4875 which is: > throw new IllegalStateException("Unable to acquire bundle lock, thread interrupted."); > I dug around and discovered the thread which acquired the lock was the one created on JettyService.java:75 > Looking at usages of the thread field, I think I discovered the source of the interrupt on line JettyService.java:75. > What I think is happening is this: > 1. felix container starts jetty bundle > 2. jetty activator is run which creates a new jetty service > 3. jetty service creates a new thread and initializes jetty > 4. jetty attempts to register the http service to the felix container and obtains the felix bundle lock (Felix.java:4871) > 5. at the same time something calls JettyService.update(Dictionary) which interrupts the thread in attempts to restart the jetty server > 6. this causes the felix bundle lock to be interrupted and IllegalStateException is thrown > At which point the http service is not registered and we sob quietly. > To fix this issue I think the thread jetty service creates should never leave the jetty space. When it needs to register the http service a new thread should be created so it doesn't allow the possibility of the jetty service thread to obtain a lock it shouldn't. > Alternatively in stop using interrupt() to signal change as it is dangerous! Use a java 5 concurrent lock object. > Repo case: > I can repo this case within my own system by restarting bundle "Apache Felix Http Jetty (2.2.0)" again and again, but I don't know if there is a smaller repo case. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira