The Shared Java Hosting problem

I'd love it if shared hosting for Java was a reality. I'm much more comfortable with a Java stack than LAMP, and I actually think that Java has a lot more to offer. It's ironic that a platform noted for it's isolation and security is so late in getting a shared hosting solution.

Could OSGi be the answer? A stated goal of OSGI is to allow application components to share the same VM without stepping on each others toes. Right now OSGi mainly seems to be on the desktop via Eclipse/Equinox.

Apropos of nothing: Why does OSGi see itself as a competitor to JMX (Java Management Extensions)?


Richard S. Hall said...

I don't think the OSGi Alliance has ever viewed JMX as a competitor to OSGi technology; it is complementary since it defines a way to create management API and OSGi technology does not define this. The reason they may have been confusingly thought of as competitors by some people in the beginning is that some projects (i.e., JBoss) tried to contort JMX into being a modularity layer in addition to a management layer. JMX was not intended to be used as a modularity mechanism, even though it ended up being used this way, which resulted in a half-baked solution. I think people have finally seen the error of their ways on this front, though.

josh said...

You may very well be right, Richard, however someone thinks they are competitors. From the Felix website:

"As an example of a simple use case, Felix can be easily embedded into other projects and used as a plugin or dynamic extension mechanism; it serves this purpose much better than other systems that are used for similar purposes, such as Java Management Extensions (JMX)."

It's not clear to me if this is the same as your assertion, e.g. a criticism of shoe-horning JMX into a purpose it wasn't designed for.

AlBlue said...

I think what it's saying is that OSGi is a better modular system than JMX, which isn't a modular system (but may have been treated by some). That's not to say they can't co-exist and use each other's strengths.

I don't think OSGi as a server-side sharing mechanism is good in the general case (e.g. app servers) since there's still one VM, and one VM can run out of memory. However, that's the same with other app servers (like Tomcat), and often people will spawn separate processes to host separate apps to avoid this kind of problem.

There's no reason OSGi can't be used though, because then you get to mix-and-match ability to run everything in one VM or in separate VMs as the person chooses. What it does give you is the ability to assemble applications from modules, rather than as big monolithic units.