I’ve been able to find why Eclipse doesn’t update the classes for OSGi in some cases. To find when is starts going wrong. I got the hint here at Apache Felix FAQ.
I was using cross-references. My bundles:
DAOLayer was using com.ak.domain.WebSite and exporting com.ak.dao.WebSiteDAO
MainLayer was using com.ak.dao.WebSiteDAO and exporting com.ak.domain.WebSite
So when I remove this cross-reference, it starts updating classes. This, however, doesn’t happen in all cases. Seems like it stops working only when the classes in cross-referenced packages also reference each other.
Over all, here are the conclusions:
1. Don’t cross-reference packages that rely on each other. Maybe it’s OSGi problem.
2. If bundle A has package package1 and bundle B has package with the same name (package1), then bundle B can not export this package for bundle A to use.
3. !!IMPORTANT!! Let’s say we’ve got BundleA and BundleB. If BundleB uses SomeClass in a method that is called by BundleA (even if BundleA has no idea of SomeClass), you need to explicitly export package of SomeClass in BundleB.
Again,
IF (
BundleB / package com.Big / BigClass has method:
public void printSmth () { new com.small.SomeClass(); }
AND BundleA imports com.Big in order to call com.Big.BigClass.printSmth(),
) THEN {
BundleB has to export com.small package
}
— doesn’t make too much sense, but this is how it works for me.
To fix all the problems, I moved Website class to DAOLayer. I know its better place is in MainLayer, but it won’t work this way. They (WebSite and WebSiteDAO) are too tightly coupled and therefore don’t work if they’re in different bundles.