GlassFish V3 runs on OSGi

As some of you may remember when I introduced the HK2 project last year, I described it as a friendly environment to OSGi where we would eventually be capable of running GlassFish V3 on top of an OSGi runtime. Thanks to the good work of Sahoo, this vision has finally been completed and I am happy to report that since last week, we are now capable to run GlassFish V3 on top of Apache Felix, one of the OSGi runtime available to the open source community.


In fact, we have also tried KnopflerFish (I like the name of course) and it runs fine so we are pretty confident that any OSGi runtime will be supported with minimum effort.


Now the interesting question that everyone will be asking soon, are we switching to OSGi as our underlying module subsystem ? Today I can say yes, we will. Some people might say that we changed our mind about OSGi, we didn't. From the beginning I always said we wanted to be friendly to OSGi, we just realized that vision... It is pretty clear that there is a big industry support for OSGi and it is important that GlassFish can be part of that excitement. I cannot commit on which implementation we will eventually use because we are still experimenting with some of them and we need to following conditions to be met :


    \* open source

    \* friendly license to one of our dual open source licenses as well as to our Java EE licensees.

    \* good community (forums, mailing list) to get our questions answered

    \* possibility of a commiter to be able to push our bug fixes.


Whichever implementation we choose will get a huge boost from this endorsement because we will certainly have engineers capable of fixing bugs, adding features but also we have top performance engineers at Sun that will help with the overall performance of the OSGi runtime. 


Sahoo will probably blog in a day or two explaining in details the technicalities of the solution we adopted but let me introduce it here. We are still capable of running in both HK2 mode and in OSGi mode, I am not sure how long we will maintain the HK2 mode but so far the startup is a lot faster in HK2 (1 second) versus OSGi (2 seconds). Ok no big deal I suppose but we will work on that. It's hardly surprising that HK2 is faster, it is not meant to be a generic modular subsystem like OSGi, it is quite optimized for our V3 work !


None of GlassFish code depends on OSGi libraries (or very very little), we isolated those dependencies in HK2 which makes it very easy for us to switch OSGi runtimes or even module management runtime with no code changes. The HK2 project will continue as it is offering a lot more than just module management, in particular we have the following features that we continue to use heavily :


    \* module management isolation layer

    \* module management through Repositories (coming in OSGi R5)

    \* lightweight component model

    \* dependency injection 

    \* configuration handling


So if you want to play with the OSGi version of GlassFish V3, I would recommend downloading the latest binaries from there.

It's our latest build, don't expect miracle and please file bugs when you find one.

 

and to run GlassFish in OSGi mode, simply do from your installation directory

    	java -DGlassFish_Platform=Felix -jar modules/glassfish-10.0-SNAPSHOT.jar

to run in hk2 mode, just do

	java -jar modules/glassfish-10.0-SNAPSHOT.jar 
Comments:

Nice blog, Jerome. I am sure this will take GlassFish to an even higher plane. Yes, some more details to follow soon.

Posted by sahoo on April 11, 2008 at 05:39 PM PDT #

Great news, it's always nice to see that even big projects like GlassFish can be migrated to OSGi. Congratulations on the excellent work!

Posted by Marcel Offermans on April 12, 2008 at 01:55 AM PDT #

Congratulations! This is wonderful news, the more projects use the same modularization layer, the more value it gets for us all. It would be really nice if some people from the Glassfish community could also participate in the enterprise expert group?

Peter Kriens

Posted by Peter Kriens on April 13, 2008 at 03:50 PM PDT #

Is Equinox also in the list of possible runtimes?

Posted by Sakuraba on April 14, 2008 at 02:35 AM PDT #

yes equinox is on the list, we should have some information available shortly.

Posted by Jerome Dochez on April 14, 2008 at 07:19 AM PDT #

Just a small question -
Does this signal that HK2 will be discontinued? I have been waiting for long time for working with/on HK2 but did not get any response so I just wanted to know whether my "wait" will ever end :).

Posted by Imran M Yousuf on April 14, 2008 at 12:50 PM PDT #

Will this have any influence on supporting JSR-277? Until now it didn't look like OSGi and JSR-277 would play well together.

Posted by writtmeyer on April 14, 2008 at 09:25 PM PDT #

Imran

No it does not mean that HK2 is discontinued, we certainly are continuing all the service level (and above features), we don't have plans to discontinue the module management either if you feel like using it.

Posted by guest on April 15, 2008 at 06:45 AM PDT #

Jerome,

If you need any help with Equinox, feel free to contact me. I'd be happy to introduce you to the appropriate people.

Ian Skerrett
Eclipse Foundation

Posted by Ian Skerrett on April 15, 2008 at 10:32 PM PDT #

Can I deploy a JCA module with dependendy to OSGi bundles I deploy along with the container?

JPOX (JDO, JPA) bundles could be deployed in OSGi container, and would be great to deploy the JPOX JCA module with dependency to these JPOX bundles.

Posted by Erik on April 16, 2008 at 12:38 AM PDT #

Fantastic newsh, however, when you say "runs on OSGi" are you saying that Glassfish (i.e. what I understand to be the J2EE layer) is a bundle itself? Or does the OSGi container run within the application server?

Ideally I would like to be able to deploy Glassfish to other OSGi platforms such as Equinox (as mentioned above), rather than having to inject the OSGi platform in to the application server.

Thanks,
Chris

Posted by Christopher Brind on April 16, 2008 at 01:46 AM PDT #

Erik

I would be happy to help anyway I can to do this but I have not tried JPOX, can you contact us at dev@glassfish.java.net so we can start an email thread on how to do this.

Thanks

Posted by Jerome Dochez on April 16, 2008 at 03:31 AM PDT #

Hi Jerome,

This is an interesting and beneficial development for Glassfish. As I blogged about recently, javaee containers are increasingly moving to an internal osgi backplane, which greatly eases the integration with 3rd party components:

http://blogs.webtide.com/janb/2008/04/11/1207874040000.html

From a jetty perspective, this is also terrific news. We integrated jetty with Glassfish v2, even though it was not specifically designed to have a pluggable web tier. That job will now be even easier, given jetty's long-standing usage as the Http Service in numerous osgi containers.

cheers
Jan

Posted by Jan Bartel on April 16, 2008 at 11:19 AM PDT #

Jerome,

Je suis un peu perdu ... Quel est la position des équipes de GF par rapport au JSR Java Module toujours en cours de spec ?

A+
JB

Posted by BJB on April 16, 2008 at 06:06 PM PDT #

Sorry for such as big post, i know it's not the forum, but! I have problems with this:
"C:\\Program Files\\Java\\jdk1.6.0_05\\bin\\java.exe" -DGlassFish_Platform=Felix -jar modules/glassfish-10.0-SNAPSHOT.jar 2>>errFile 1>>&2

errFile contents:
Apr 17, 2008 11:41:37 AM com.sun.enterprise.glassfish.bootstrap.ASMain main
INFO: Launching GlassFish on Apache Felix OSGi platform
Apr 17, 2008 11:41:37 AM com.sun.enterprise.glassfish.bootstrap.ASMainOSGi getSharedRepos
INFO: C:\\glassfish\\domains\\domain1\\lib does not exist

Welcome to Felix.
=================

Apr 17, 2008 11:41:38 AM HK2Main start
INFO: contextRootDir = C:\\glassfish\\modules
org.osgi.framework.BundleException: Bundle symbolic name and version are not unique.
at org.apache.felix.framework.Felix.createModule(Felix.java:3390)
at org.apache.felix.framework.Felix.createBundleInfo(Felix.java:3331)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2280)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2194)
at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:132)
at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:110)
at org.jvnet.hk2.osgiadapter.OSGiModulesRegistryImpl.newModule(OSGiModulesRegistryImpl.java:89)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.getModules(AbstractModulesRegistryImpl.java:342)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createHabitat(AbstractModulesRegistryImpl.java:132)
at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:130)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:589)
at org.apache.felix.framework.Felix._startBundle(Felix.java:1585)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1519)
at org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:1104)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:258)
at java.lang.Thread.run(Thread.java:619)
Apr 17, 2008 11:41:44 AM OSGiModulesRegistryImpl add
WARNING: Exception org.osgi.framework.BundleException: Could not create bundle object. while adding location = file:/C:/glassfish/modules/hk2-0.2-SNAPSHOT.jar
Apr 17, 2008 11:41:45 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.core.kernel [51]
Apr 17, 2008 11:41:45 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.common.amx-impl [46]
Apr 17, 2008 11:41:45 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: HK2 initialized in 7453 ms
Apr 17, 2008 11:41:45 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.common.glassfish-naming [7]
Apr 17, 2008 11:41:45 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.naming.impl.ServicesHookup@de1b8a Init done in 7500 ms
Apr 17, 2008 11:41:45 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.common.glassfish-mbeanserver [20]
Apr 17, 2008 11:41:45 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: org.glassfish.admin.mbeanserver.AppserverMBeanServerFactory@6fa9fc Init done in 7516 ms
Apr 17, 2008 11:41:45 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.server.Globals@7736bd Init done in 7516 ms
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.services.impl.LogManagerService@1d53f5b Init done in 7563 ms
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.services.impl.CmdLineParamProcessor@1ad98ef Init done in 7578 ms
Apr 17, 2008 11:41:46 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.admin.config-api [42]
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.server.SystemTasks@50ca0c Init done in 7672 ms
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.services.impl.HouseKeeper@b1aebf Init done in 7672 ms
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 8080
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: pewebcontainer.all_ssl_protocols_disabled
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.services.impl.GrizzlyEmbeddedHttpConfigurator configureSSL
WARNING: pewebcontainer.all_ssl_ciphers_disabled
Apr 17, 2008 11:41:46 AM
INFO: JMXMP connector server URL = service:jmx:jmxmp://localhost:8888
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 8181
Apr 17, 2008 11:41:46 AM com.sun.enterprise.v3.services.impl.GrizzlyProxy start
INFO: Listening on port 4848
Apr 17, 2008 11:41:47 AM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setContextRoot
INFO: Admin Console Adapter: context root: /admin
Apr 17, 2008 11:41:47 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: com.sun.enterprise.v3.services.impl.GrizzlyService@29ac startup done in 8578 ms
Apr 17, 2008 11:41:47 AM OSGiModuleImpl loadClass
INFO: Started bundle org.glassfish.common.common-util [28]
Apr 17, 2008 11:41:47 AM com.sun.enterprise.v3.services.impl.ApplicationLoaderService postConstruct
INFO: loader service postConstruct started at 1208421707123
Apr 17, 2008 11:41:47 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Application Loader startup done in 8672 ms
Apr 17, 2008 11:41:47 AM com.sun.enterprise.v3.server.AppServerStartup run
INFO: Glassfish v3 started in 8672 ms
Apr 17, 2008 11:41:47 AM com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter ready
INFO: AdminConsoleAdapter is ready ...
Apr 17, 2008 11:41:47 AM com.sun.enterprise.glassfish.bootstrap.ASMainFelix launchOSGiFW
INFO: Framework successfully started

Posted by Leonid Maslov on April 16, 2008 at 06:43 PM PDT #

Leonid, the exception can be safely ignored for now. It will be integrated in the FAQ. See also this:
https://glassfish.dev.java.net/servlets/ReadMsg?list=users&msgNo=17796

Posted by Alexis MP on April 16, 2008 at 11:14 PM PDT #

jerome, i'd like to stay close to Sun projects, so rather than using Eclipse with Felix, is there a combination that includes Felix (or another implementation of OSGi), Netbeans and Glassfish?

Posted by tom scott on April 22, 2008 at 10:59 AM PDT #

To Tom Scott:
Can you clarify what you want to achieve with GlassFish and OSGI?
Eclipse is based on OSGI, but do you want to run GlassFish V3 embedded inside the Eclipse IDE or as an external process? If you want the external process, then either Eclipse or NetBeans (that you seems to prefer) would work in terms or developing Java SE applications that can be run/debug via the IDE (both of them).

Thanks for giving us more information, so that we can fine tune either NetBeans (that already has a fantastic GlassFish V2 and V3 integration) or Eclipse (that can run Glassfish V3 TP2 in embedded mode, with some bugs we are trying to address).

Ludo

Posted by Ludo (Ludovic Champenois) on April 29, 2008 at 02:28 PM PDT #

This is very good news. Modularity is the key solution to devolep today's complex and big applications. OSGI will bring the power of modularity with better support for modular architecture

Posted by Iskender Yigitel on May 09, 2008 at 08:10 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

dochez

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today