Provide osgi informations in hibernate MANIFEST.MF to be recognized as osgi-bundle


Hi all,

It would be great if the packaging of Hibernate could be done as osgi compatible jar. With little configuration, some plugins already exist to do it in simply.
For informaiton, a jar can become osgi-compatible only by adding some properties inside the META-INF/MANIFEST.MF file. It lets the jar totally usable in a non-osgi environment, but let the jar be recognized as a "bundle" in an osgi-container (Eclipse, Apache Felix...).

A good entrypoint for this, using maven2 to package, could be

For example, Spring already did and their available jars on can be put directly in a eclipse/plugins directory and be recognized as a bundle/plugin.





Baptiste Mathus
March 30, 2008, 8:15 PM

Well, I'm no OSGi expert. But from my understanding, yes, dependencies also have to be present and osgi-compatible. But that's like project management, it's not your role to provide those jars osgi-ly. For example, in our company we have repackaged jars to be able to use them inside the "plugins" directory of Eclipse.

With OSGI, in the MANIFEST, basically you have to provide a "Bundle-symbolicName" (org.hibernate.hibernate-core for example), Export-Package and Import-Package (a Require-Bundle keyword also exist, but it's just a less-granular way of declaring dependencies against packages: see for more information).

Happily enough, a tool has been developed to be able automatically generate those informations: BND, cf. Btw, one of the samples using BND has been done with hibernate:

And last but not least, maven-bundle-plugin is actually a maven plugin that uses BND library.

Some minutes ago, I quicky tested it and was able to generate a seemingly osgi compatible hibernate-core-3.3.SNAPSHOT jar (I'm going to attach the patch). To see if a jar is visible in an osgi container, I usually open Eclipse, drop the jar in plugins directory, window/preferences/Target platform. Then hit reload. For the current example, if you see org.hibernate.hibernate-core appear, then it's OK.

For more information, see also:

Baptiste Mathus
March 30, 2008, 8:22 PM

Small patch on the hibernate-core pom.xml to use maven-bundle-plugin to package hibernate-core so that it's osgi-compatible.

Max Rydahl Andersen
March 31, 2008, 9:28 AM

Yes, I know all this but did you actually try and run this inside eclipse ?

Just because we stick some declarations into hibernate.jar does not make it actually work inside eclipse.

How did you test this ? Did you osgify all the other dependencies ?

Did classloading of user classes work correctly for you ?

Eric Jain
April 10, 2011, 1:48 AM

Isn't Hibernate 4 planning to support OSGi anyway (see Meanwhile, you could either use SpringSource's (outdated) version of Hibernate, or switch to EclipseLink.

Steve Ebersole
August 16, 2012, 2:46 AM

Discussion moved to

Out of Date




Baptiste Mathus

Fix versions






Suitable for new contributors


Requires Release Note


Pull Request





Affects versions