• Post Reply Bookmark Topic Watch Topic
  • New Topic

OSGI alternative  RSS feed

 
Swapna Sharan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is nightmare to use OSGI with all of it's bundle installation/loading issues and classnotfound issue. Is there any alternative for it ?
 
Tim Moores
Saloon Keeper
Posts: 4034
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OSGi is non-trivial for sure, but worth its learning curve IMO. To advise on alternatives, you need to tell us what you intended to use it for.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The alternative is not to use it!

We have moved away from OSGi and our application suite is composed of a set of Microservices, containerised in Docker! We are now in the process of introducing some container management tool that would enable us to orchestrate Docker containers!
 
Stephan van Hulst
Saloon Keeper
Posts: 7991
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe, how does Docker replace what OSGi does?
 
Tim Holloway
Saloon Keeper
Posts: 18797
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't.

OSGi is a framework similar to how web application servers work, except that the services may not be web-based or even networking-based. It essentially allows a JVM to be partitioned up into different application spaces with unique and non-conflicting classpaths and allows modules to interconnect without physically binding them into a single execution unit. Because of the built-in classpath isolation, OSGi has, in fact been used as the framework to implement web application servers.

Containers are miniature VMs, running discrete programs, which may or may not be Java programs. While some Java applications could at the designer's option be either OSGi or stand-alone apps containerize, Docker containers have much more OS resource overhead, even though less than a full VM would. In fact, even running multiple JVMs, one per app natively is going to have a lot more resource overhead than one JVM hosting multiple lightweight OSGi apps.

If an app is so critical that living in an OSGi container is undesirable and you'd prefer that it run stand-alone, with the real-time cross-machine portability that containers support, then by all means Dockerize it. But my OSGi server (Apache ServiceMix) itself runs as a Docker container.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java 9 is going to have its own module system (Java 9 is not out yet at this moment, so you can't really use it yet).

It will have some of the same features as OSGi, but it won't be able to dynamically start / stop and replace modules like OSGi does.
 
Stephan van Hulst
Saloon Keeper
Posts: 7991
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really understand the concept of using Docker together with Java. To me it appears that Docker containers are like lightweight VMs so applications can easily run cross-platform. Isn't this already the whole idea behind the JVM itself?

I also don't understand how any of these features address Swapna's original question. OSGi is a framework for plugging in modules dynamically as far as I understand it, and it appears Swapna would like another framework that does this more easily. The only thing I can think of is something like NetBeans Platform Module System, although it's not necessarily easier than OSGi.

I'm sure I'm completely misunderstanding Joe's suggestion, but I'm eager to learn more about these technologies.
 
Tim Holloway
Saloon Keeper
Posts: 18797
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JVM-based apps are not self-contained. To run the Tomcat webapp server, for example, you have to have 2 separate directory structures for the server itself (although by default they overlap). Plus whatever additional OS resources the webapps themselves may tap into.

So it's much more convenient to containerize the whole ball of wax except for maybe a few external resources. That way you can easily spin up multiple copies and/or bounce instances from one container server to another for load balancing and business continuity purposes. Accordingly, I have Docker JVMs for ServiceMix, Jenkins, Nexus, and several webservers.

I worked with a precursor to OSGi and it was no picnic. If OSGi seems complex, it's because it's also capable. But with the right build resources you can do a lot towards taming it.

Actually, if you want modularity without OSGi, most people would probably start with the Spring Framework.

Although Spring itself supports OSGi.
 
Stephan van Hulst
Saloon Keeper
Posts: 7991
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting, thanks Tim! I'll check it out a bit more.

Sorry if I hijacked your thread Swapna, I hope you managed to get some answers?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!