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 A67A5102D7 for ; Sun, 29 Sep 2013 09:29:41 +0000 (UTC) Received: (qmail 5681 invoked by uid 500); 29 Sep 2013 09:29:10 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 5483 invoked by uid 500); 29 Sep 2013 09:28:53 -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 5309 invoked by uid 99); 29 Sep 2013 09:28:42 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Sep 2013 09:28:42 +0000 Date: Sun, 29 Sep 2013 09:28:41 +0000 (UTC) From: "J.W. Janssen (JIRA)" To: dev@felix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FELIX-4234) Using HttpService provided by Felix Jetty bundle 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-4234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13781323#comment-13781323 ] J.W. Janssen commented on FELIX-4234: ------------------------------------- Most probably, your little bundle is started while the HTTP bundle is still starting (bundles start often asynchronously from their bundle activator). Because of this, the HTTP service is not yet registered and therefore you cannot grab a service reference to it. There are two solutions for solving this: 1. the most simple one: register your Servlet whiteboard style (see [this page|http://felix.apache.org/documentation/subprojects/apache-felix-http-service.html#using-the-whiteboard]) and add the `org.apache.felix.http.whiteboard` bundle to your set up. This bundle will automatically register all Servlets registered with the OSGi framework with the available HTTP service; 2. use a ServiceTracker (or any other dependency tracking mechanism, such as DS or Felix DependencyManager) to register/deregister your servlet when the HttpService actually becomes available. I will update the Felix HTTP service documentation a little to document the latter approach, as it is somewhat misleading in how it should work... > Using HttpService provided by Felix Jetty bundle > ------------------------------------------------ > > Key: FELIX-4234 > URL: https://issues.apache.org/jira/browse/FELIX-4234 > Project: Felix > Issue Type: Test > Components: HTTP Service > Affects Versions: http-2.2.0 > Environment: Several hardware configurations > Operating System Ubuntu 12.10 amd64 > Reporter: Luca Capano > Labels: jetty, newbie, test > Fix For: http-2.2.0 > > > I'm new in using Felix implementation of OSGi and I'm trying to start the Jetty bundle and register a simple servlet, but I have a problem in getting the Service Reference of HttpService. In details, I made the following steps: > 1) Get Felix framework from the proper site > 2) Get the Jetty bundle (org.apache.felix.http.jetty) from the same site and insert it in the /bundle folder (the auto-deploy folder) > 3) Write my little training bundle made by Activator+Little servlet+Manifest file > 4) Create a jar of my bundle > 5) Put the jar into /bundle folder (the same where Jetty bundle is put in) > 6) In the config.properties file write the property org.apache.felix.http.enable=true > 7) Start the felix framework typing "sudo java -jar /bin/felix.jar" from the install folder of felix > In this way it seems that Jetty starts on localhost:8080 (I see 404 Error into the browser), but I have no reference for HttpService. In details, in the activator I have this line: > ServiceReference ref=context.getServiceReference(HttpService.class.getName()); > but ref is always null. The same happens if I start Jetty and then my little bundle. What am I doing wrong? -- This message was sent by Atlassian JIRA (v6.1#6144)