Setting up Felix HttpService

Well, every once in a year it is good to try to code something and not just write BS docs. Well as usual this time I am monkeying with getting a webapp running inside the Felix OSGI container. So what is the problem?

Well, First off, the documentation just says to download the Felix HttpService and use it. Then all documentation tells me to use it but there is no documentation on how to actually deploy it. So I download the “Felix http bundle” from the Felix website. Well, at least I download the “.tar.gz” file thinking it should include some docs and the service implementation. Nope, a single source file and  a license text file. Eh? Well then after downloading plenty of other “http” files from the Felix website I finally decide to try to “jar” file separately. And yes, it contains a plenty of class files.

So after finally finding the correct file (the Felix Http Bundle JAR file), I set about trying to install it. So I add it to my bundle classpath and try to use it. Put in the bundle classpath and all that. Of course, it is an epix failure. So I start to browse the contents of the jar file to see what it is about. Well, after plenty of searching and initial misses, I finally find it has a So I try to deploy it as a bundle in Felix. Oof, it loads. Maybe now it works?

Nope, lots of classpath exceptions. First off, I add the javax.servlet and javax.servlet.http to imports for my own bundle. Similarly for the osgi http service package. So maybe now my code runs and finds the Felix OSGI HttpService? Nope. Well, of course the basic failure is that you need to start the HTTP bundle before your own bundle to see it. But even after that, all it finds is a service registered under the name of HttpServlet, not HttpService. Eh?

Well.. Turns out (by browsing the .tar.gz java source code for the activator and finally some docs after that) that you need to configure Felix to start the embedded Jetty container as by default all containers it includes are disabled. Thanks for (not) documenting that. So add “org.apache.felix.http.jettyEnabled=true” into Felix Ah yes, it tries to do something. Since it gives a failure to find the ManagementService class file. Well, from previous browsing of the Felix HTTP service activator I know it tries to load something like that. And in the for the HTTP service this is set to “optional” in resolving. So what gives, it should load right? It seems to be something belonging to OSGI itself right? Guess NOT.

So what next? I recall from all my googleing for these failures that someone was complaining about hard dependencies to a ConfigAdmin service somewhere. And yes, the docs mention you can use that. So I try to deploy the ConfigAdmin bundle. Oh yes, it works now. Thanks for (NOT) documenting that.

Well, finally the servlet runs. Now just to wonder what is the next failure..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s