OSGi on AppEngine?

As many people know, Google recently announced support for Java on its AppEngine platform. As a connoisseur of OSGi, the first natural thing that came across my mind was quickly I could get OSGi running on it. Well, I’m happy to announce that we are part way there. I have OSGi running locally on the AppEngine SDK using the Equinox servlet bridge. I’ve managed to get a basic environment running with Equinox (and some bits of p2) and the Knoplerfish console:


This wasn’t easy and was full of problems. If you read the AppEngine documentation, the sandbox is quite restrictive. First, there were a few places we were setting the context classloader and AppEngine doesn’t like that. I managed to hack the Equinox servlet bridge and the Equinox http service to not do that (it’s only needed in certain cases). Second, there’s a JRE “whitelist” of classes you can access that can cause trouble. I think this isn’t much of a problem if we define a custom OSGi execution environment for AppEngine. I attempted to do this since in Eclipse 3.5, we support the definition of custom execution environments. However, I found that the current whitelist doesn’t seem to be complete (maybe someone from Google can help). If you solve those problems, you can get Equinox working locally within the AppEngine SDK (as seen in the screenshot above). Here’s a zipped project if you’re interested (see the Equinox OSGi shared launch configuration and just go to localhost:8080/console).

In reality, this is only half of the battle. If we actually try to deploy what we have created above, things will fail. The most complicated problem I came across with running OSGi on AppEngine was you can’t write anywhere to the file system. Equinox and other OSGi frameworks need a place to write its state.  I think we can get around this if we write a custom storage adaptor hook in Equinox that uses the AppEngine storage facilities, however, that’s going to take some effort.

That’s it for now. I plan on making some more progress next week… are there any other people that want to see OSGi running on AppEngine? Have any other people out there been experimenting with OSGi and AppEngine? Did you hit the same roadblocks? Do you want to collaborate?

  • Posted at 14:48, 2009-04-10


    That sounds exciting ! How much cost to code the adapter to use JDO ?


  • Posted at 16:14, 2009-04-10

    Nice work, will be cool to see it running on the actual AppEngine 🙂

    BTW, you also can’t create threads in the actual AppEngine sandbox (it’s primarily request driven along with a cron scheduler service for admin tasks, each request/cron task is limited to 30s) – but there’s probably a fair bit of OSGi functionality that would still work inside a single thread…

  • Pascal
    Posted at 17:01, 2009-04-10

    How did you work around the limitation of thread creation? Equinox needs a slew of them for the purpose of event delivery.

  • Marcel Offermans
    Posted at 18:17, 2009-04-10

    This all sounds a bit like the restrictions Google Android has (which also places some restrictions that complicate running OSGi). Abstracting the OSGi bundle cache itself to use a different API sounds possible, but the bundle data store is built on top of the File abstraction, which is not that good an abstraction. 😉 Running OSGi in cloud like environments is definitely something I’m interested in though.

  • Eric Newcomer
    Posted at 17:32, 2009-04-10

    Chris – are you sure this will work? Last I read about AppEngine it was a way to fit Web apps onto the Google infrastructure, which is all highly customized, for “automatic” scale out. Aren’t the Google APIs sort of required?


  • Eric Newcomer
    Posted at 18:21, 2009-04-10

    I don’t know, I just imagined the Google APIs would create some difficulties, but if they provide a JDO adapter maybe they have anticipated the issues.

    Ok, well, interesting experiment! I look forward to hearing more about it.



  • Posted at 22:34, 2009-04-10


    This looks really interesting. I would love to see Equinox / OSGi running on the app engine – obviously RAP too 😉


  • Jochen Hiller
    Posted at 10:12, 2009-04-12

    Hi Chris,

    cool. I will support you making OSGi running on Google AppEngine, if its really possible !?
    I think the threading limitations will be the most difficult part to address when bringing an OSGi implementation on GAE.


  • Brandon
    Posted at 16:42, 2009-04-13

    Have you tried the Prosyst Android OSGi platform on Android yet? Works pretty well though still in development it seems.

  • Neil Laurance
    Posted at 05:49, 2009-04-15

    Nice one. Look forward to the next installment. Will have to download your sample project and have a tinker.

  • Posted at 07:55, 2009-05-09

    Hi Chris,

    I have also started my experiments with getting OSGi to run on AppEngine.


    Because of the restrictions imposed there, I do not think it is possible
    to get a complete OSGi-R4-compliant framework, but we might want to settle
    for a reasonably useful subset thereof. Useful as in: Can run (many) OSGi bundles
    without the need to modify them.

    Three big roadblocks so far:

    1) no threads: This means that we cannot start bundles or propagate events
    asynchronously. Everything has to happen on the main thread. I can live with that.

    2) no files: This means no bundle cache, and no persistent bundle state.
    I think we have to give up on bundle state (persistent or not) anyway, because
    in App Engine, we are spread over multiple JVM. So our whole application
    (including the framework) has to be mostly stateless. Dynamically starting bundles
    for example is not useful unless it happens across all servers.

    3) SecurityManager does not like bundle classloaders.
    You can construct OSGi classloaders on AppEngine (I have that part of Felix working),
    but code running on them is much more severly restricted than code
    running on the “main” classloader. Reflection for example does not work at all.


    1)+2) can be dealt with in the framework, but 3) seems to be a problem.
    Neither the Pax Web Extender Whiteboard (needs reflection) or the Equinox HttpService Servlet
    (needs Thread.currentThread().getContextClassLoader) bundles can be
    used (unmodified) because of that.

  • satya
    Posted at 15:13, 2009-05-21

    I am also trying to run my osgi web app on google appengine but with no success yet. But after seeing your blog I am now hopeful about it.

  • duduzerah
    Posted at 21:21, 2010-07-05

    Very good!!!

    And this is the final release? Any improvement after this article?