CodexBloom - Programming Q&A Platform

Eclipse 2023-09: Strange ClassLoader implementing OSGi and Dynamic Bundle Updates

πŸ‘€ Views: 0 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-14
Eclipse OSGi Java Apache Felix

I've been working on this all day and I need some guidance on I'm working on a personal project and I'm sure I'm missing something obvious here, but I'm working with a perplexing scenario with my OSGi application in Eclipse 2023-09... While trying to dynamically update a bundle, I noticed that the changes are not being picked up correctly, leading to `ClassNotFoundException` for classes that are supposed to be part of the updated bundle. For example, when I modify the `MyService` class in `com.example.mybundle`, I am expecting the updated version to be loaded, but instead, I get this behavior: ``` Exception in thread "main" org.osgi.framework.BundleException: Unable to resolve com.example.mybundle [1](R 1.0.0): missing requirement [com.example.mybundle [1](R 1.0.0)] osgi.wiring.package; (osgi.wiring.package=com.example.services) ``` I've tried cleaning the projects and refreshing the workspace, and even removed and re-added the bundle in the OSGi runtime environment. I also ensured that all dependencies are correctly defined in the `MANIFEST.MF`. My current setup uses Apache Felix as the OSGi container and the following `MANIFEST.MF` configuration: ``` Bundle-ManifestVersion: 2 Bundle-Name: My Bundle Bundle-SymbolicName: com.example.mybundle Bundle-Version: 1.0.0 Import-Package: org.osgi.framework;version="1.8.0" Export-Package: com.example.services;version="1.0.0" ``` The `com.example.services` package, which is supposed to be exported, contains the `MyService` class that’s being referenced. I also ensured that the correct version of the package is being exported and that there are no version mismatches. Additionally, in the Eclipse OSGi console, I can see the bundle in a resolved state, but it appears that updates are not being applied correctly. What could be causing this scenario? Are there specific configurations or settings in Eclipse or the OSGi runtime that I might be overlooking to ensure dynamic updates work seamlessly? This is part of a larger web app I'm building. This is part of a larger service I'm building. Any ideas what could be causing this? Hoping someone can shed some light on this. I recently upgraded to Java stable. Is there a simpler solution I'm overlooking?