Skip to main content

EJB as OSGi Service demo at eclipsecon

Posted by ss141213 on March 30, 2010 at 6:45 PM PDT

I will wrap up my experience at eclipsecon. This was my first time at eclipsecon. Folks who had been here earlier told me that this year there was a lot of topics around eclipse runtime projects – so the focus has shifted from tools to runtime. Overall I liked eclipsecon.

My topic, OSGi & Java EE in GlassFish, was also of the same type. The slides of my talk are available here. The source code for the sample used to demonstrate “Modularized Enterprise Java Application” running in GlassFish is now available here. Just download, unzip and run it following the steps listed below.


The sample is organized as shown in the UML diagram below:


Features of the sample

All the components including the EJB are deployed as separate OSGi bundle.

EJB uses JPA in container managed mode to communicate with the database.

Both the admin client and Web Application Bundle client use the EJB via OSGi service registry.

Deployment order of bundles is irrelevant.

Local EJBs being accessed from other bundles.


Steps to run the sample:

asadmin start-domain

cp osgi-ejb-container.jar osgi-jpa,jar from maven repo to ${glassfish.home}/modules//autostart/

asadmin start-database


cd ./ejb-as-service

mvn clean install

cp ./common/target/hybridapp2-common.jar ./client/target/hybridapp2-client.jar ./service/target/hybridapp2-service.jar ./webclient/target/hybridapp2-webclient.war $glassfish.home/domains/domain1/autodeploy/bundles/

Open http://localhost:8080/eclipsecon/


Look at the source code, the metadata in jar files, and experiment. If you have any questions about OSGi & Java EE, send emails to


ejb-as-service.zip48.78 KB
diagram.png25.3 KB


Nice...but netbeans support?

Sahoo, Very nice simple example. I particularly like the use of JPA within your EJB, to show this is working well. Do you know if there is any planned Netbeans support for EJB's in OSGi modules? I'm sure this would be difficult, since currently the OSGi module development leverages the NBM project development, which of course EJB's wouldn't be applicable. It would be great, though, if I had IDE support for EJB's in this type of project. Thanks, Steve

netbeans support

Do we need extra plugin in NetBeans for developing such projects? Does NetBeans not support maven based Java EE projects? If it does, then I don't see why one can't leverage that to develop hybrid applications.