4

I am trying to deploy guice into JBoss AS7 (7.2.0-Alpha). This comes as a number of jars. The ones I am interested in are

  • guice
  • guice-servlet
  • guice-persist

guice is the a host bundle and guice-servlet and guice-persist are fragments of this host.

When I start the container the host bundle always gets installed, resolved and becomes active. The fragments always get installed and sometimes get resolved and "included" in the host bundle and sometimes don't. This seems to be random.

I have also tried Eclipse Virgo and the behaviour is the same, but, it has the ability to define plans whereby you can circumvent this problem by defining the installation order. (I seemed to be able to make it work anyway).

Looking at the OSGi spec and reading the answer to this question it seems like this is the expected behaviour. JBoss is an OSGi 4.2 container so the the Require-Capability and Provide-Capability headers aren't an option - plus I don't really want to modify jars which aren't mine.

How am I supposed to get my host/fragment bundles to install and resolve reliably?

One idea I have had (which I am reluctant to do as it doesn't seem right) is to use maven-bundle-plugin/bndtools and merge the guice bundles together into a single super-guice-bundle - effectively doing at build time what the container is failing to do for me at runtme.

1 Answer 1

8

As I said in my answer to the question you linked to: the fragment will be attached to the host if it is installed before the host resolves. The easiest way to achieve this is to install all bundles (including fragments) first, before allowing any of them to resolve.

In many cases the resolve is triggered by trying to start a bundle. One of the most common errors people make in OSGi is trying to start each bundle immediately after it is installed. You must not do this, i.e. you should not start any bundle until after you have installed all bundles that you intend to run.

3
  • Thanks, that makes it quite clear. It seems my version of JBoss is choosing to install and then resolve the host bundle straight afterwards. Not quite sure why. Probably a question for the JBoss OSGi guys. Nov 15, 2012 at 10:20
  • It seems in JBoss that if I deploy my bundles in the "bundles" folder structure it installs all the bundles first and then resolves only as and when needed. If I deploy into the "deployments" folder, typically used for hot deployment, it installs and resolves each bundle individually - leading to my issues. Nov 15, 2012 at 10:50
  • I think you have some extra words in the first sentence, I can't quite parse your meaning: "the fragment will be attached to the host of it is installed before the host resolves"
    – pimlottc
    Apr 19, 2013 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.