Question

Here's an interesting think I've observed and which has puzzled me for some time now.

I'm using Glassfish 3.1.2.2 which I deploy multiple OSGi bundles on.

When I want to replace the bundles with new versions/revisions I have to uninstall and then install bundles.

Normally, I'd assume Glassfish can reuse old bundle ids that aren't present any more, but it just continues. For example, let's say that Glassfish bundles go to ID of 100, and my own bundles start go from 101 to 200.

When I uninstall old bundles and install new ones, I'd assume that the bundle ID in range 101-200 would be reusable.

Instead, my new bundles have their IDs from 201 to 300.

I'm uninstalling them like this:

uninstall <bundle id>

and installing like this:

install file:<path-to-bundle>

How to resolve this problem so that Glassfish reuses old bundle IDs?

Edit:

I have found a folder named bundle0 in glassfish3\glassfish\domains\domain1\osgi-cache\felix which contains a file named bundle.id with a single number, which seems to be something like a DB sequence, noting the last bundle id used.

In order for me to manually change the starting bundle id with the following bundle installations, I have to do the following, in this order:

  1. Uninstall my bundles via GoGo console
  2. Stop Glassfish
  3. Delete bundle<ID> folders of my bundles in glassfish3\glassfish\domains\domain1\osgi-cache\felix
  4. Change the number in bundle.id file to some reasonable number
  5. Start Glassfish - it will increment the number in bundle.id file
  6. Install new versions of my bundles

As you can imagine, I do not want to do this every time I want to do a release/upgrade. Can Glassfish do this by itself, or do I need to create a script of some sort that will do this for me?

Was it helpful?

Solution

The OSGi spec requires bundle ids to not be reused. Note: you can update a bundle in place rather than uninstall/install. When you update, the bundle id is preserved.

OTHER TIPS

Why do you want to keep the same IDs? As BJ mentioned you're not supposed to do this, so you're probably approaching another problem the wrong way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top