users@glassfish.java.net

Re: OSGI Web bundle

From: Sahoo <Sahoo_at_Sun.COM>
Date: Tue, 20 Oct 2009 15:16:54 +0530

Hello Pavel,

I am having difficulty understanding your scenario. The relationship
between life cycle of OSGi bundle and web app is shown here:

[1]
http://weblogs.java.net/blog/ss141213/archive/2009/06/developing_hybr.html

As shown there, GlassFish OSGi Web Container deploys the web app when
the web bundle moves to STARTING state. By deploying a web app, I mean a
ServletContext is created for the web app. A bundle context is already
associated with an OSGi bundle in STARTING state.

Please see more response inline...


Pavel Kuzin wrote:
> Hello!
>
> I`m trying to migrate from Spring DM Server to Glassfish v3 with OSGI.
> I`m successfully deployed my OSGI bundles ( parts of application).
> And when i`m trying to install last Web Bundle then Glassfish`s
> osgi-web-container
> tries to activate web application before bundle context is activated
> and initialised.
1) What do you mean by osgi-web-container "tries to activate web
application?" osgi-web-container does not call bundle.start() or
anything like that.
2) Are you sure osgi-web-container came into picture when you
"installed" the web bundle? It is supposed to come into picture upon
receiving a STARTING event or a LAZY_ACTIVATION event.
3) How are you installing the bundles in the first place? Are you using
"asadmin deploy" command? There may be issues with that command.
Instead, can you try copying your bundles to
glassfish/domain1/autodeploy/bundles directory?

I expect this to happen:
Once you copy the bundles to that directory, FileInstall bundle will try
to start the bundle. Before the bundle is activated (i.e., bundle's
activator.start() method is called), osgi-web-container will process the
bundle and deploy it to underlying web container. Then, bundle's
activator will be called. I am not sure when spring's osgi extender
comes into picture. If it is also trying to extend the bundle in
STARTING state, there is a potential race condition between
osgi-web-container and spring-osgi-extender. If it tries to extend in
STARTED state, I don't see any issue.

Please feel free to raise your questions in this forum.

Thanks,
Sahoo