Background
Thanks to a colleague, I was „forced“ to give an internal talk about something I did extensively in the past. More than ten years ago, I was very active in open-source software development, contributing features to the Apache Karaf ecosystem, including work on the PAX Web OSGi Server (based on Jetty, Tomcat, or Undertow). Back then, it was a thrilling ride, and now, others are keeping the project alive. But what’s a talk without a sample application to demonstrate how it all works?
For this, I did some Vibe Coding—no tests, just coding and re-remembering how OSGi worked for me. AI was surprisingly helpful, and I was impressed by its knowledge of OSGi. I had about 40 minutes for the presentation, so I wanted a slide deck and a walkthrough of a sample application I developed.
The Land Before Time: When OSGi Ruled the World

Quick Fundamentals About OSGi
OSGi (Open Service Gateway Initiative) is a modular system for Java applications, enabling:
- Modularity: Applications are split into bundles (JARs with metadata) that explicitly declare dependencies.
- Dynamic Behavior: Bundles can be installed, updated, or removed at runtime—no server restart required.
- Classloader Isolation: Each bundle loads its classes in isolation, preventing version conflicts. For example, Bundle A can use com.example.lib:1.0, while Bundle B uses com.example.lib:2.0, and both coexist peacefully.
- Service-Oriented Architecture: OSGi follows the Hollywood Principle—“Don’t call us, we’ll call you.“ Bundles publish services (e.g., ChatService) to a registry, and other bundles consume them dynamically. This pattern is also reflected in the Whiteboard Pattern, where services like servlets are automatically registered and discovered, reducing hard dependencies.
- Configuration Admin: Services can be configured at runtime, and factory configurations allow multiple instances of the same service with different settings.
The Sample Application: AI Chat with OSGi
I wanted to mix my recent interest in AI with my long-standing appreciation for OSGi. So, I created an OSGi-based AI chat application:
- The backend is a service configurable via OSGi’s Configuration Admin.
- The frontend is a servlet registered as a whiteboard service.
- The goal was to demonstrate OSGi’s dynamic capabilities by allowing different chat services (e.g., Mistral’s Le Chat, a grumpier version, or a local Ollama model).
Developing with AI
I used AI tools like Claude and GitHub Copilot to help build the application. Here’s what I learned:
- Strengths: The AI was up-to-date on OSGi service development and even knew how to inject configurations via Configuration Admin.
- Challenges: It initially struggled with the Config Factory Pattern and didn’t fully grasp the whiteboard context for web services. However, it helped improve the frontend’s design beyond plain text and input fields.
- Outcome: AI was a valuable assistant, especially for someone already familiar with OSGi. For professional use, I’d enhance the AI with specialized knowledge (e.g., RAG systems).
Preparing the Presentation with AI
I didn’t spend much time creating the slide deck—I asked Le Chat to help with the content and images. The result was a polished presentation that covered:
- OSGi fundamentals.
- A live demo of the chat application.
- The dynamic nature of OSGi, showcasing multiple service instances with different configurations.
Reflection: OSGi and AI
Revisiting OSGi was a blast. AI was surprisingly effective but had its quirks:
- It helped me quickly navigate to critical parts of the code.
- It occasionally led me down the wrong path (e.g., incorrect loops or misguided suggestions).
- For professional use, I’d supplement the AI with additional context (e.g., RAG) to improve accuracy.
Key Takeaways
- OSGi’s Power: Classloader isolation and service dynamism are still unmatched for certain use cases.
- AI’s Role: AI can accelerate development, but domain expertise remains essential.
- Future Potential: If OSGi were still widely used, AI could be enhanced with specialized models or RAG systems to make development even smoother.
Conclusion
This project was a fun way to revisit OSGi and explore how AI can assist in niche domains. While OSGi may no longer be the default choice for modern Java development, its core principles—modularity, isolation, and dynamic service management—remain as powerful as ever. With the right tools (and a little help from AI), even „ancient“ technologies can not only feel fresh again but also inspire new ways of thinking about software architecture.
After all, sometimes the past isn’t just a relic—it’s a blueprint for the future.
Disclaimer: Again, thoughts are my own, but Le Chat did help again in formulating and reading before publishing.
Sources can be found in my public Github Repo:
https://github.com/ANierbeck/Karaf-LLM

Schreibe einen Kommentar