felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J.W. Janssen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-4234) Using HttpService provided by Felix Jetty bundle
Date Sun, 29 Sep 2013 09:28:41 GMT

    [ 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

View raw message