Hibernate ORM
  1. Hibernate ORM
  2. HHH-3201

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

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Out of Date
    • Affects Version/s: 3.2.5
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Last commented by a user?:
      true

      Description

      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 http://felix.apache.org/site/maven-bundle-plugin-bnd.html#MavenBundlePlugin(BND)-AddingOSGimetadatatoexistingprojectswithoutchangingthepackagingtype.

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

      Cheers.

        Issue Links

          Activity

          Hide
          Max Rydahl Andersen added a comment -

          if you could tell me how we could do that, e.g. a patch then that would help.

          What about dependent jars ? afaik these needs to be osgi-fied too....and they aren't afaik.

          Show
          Max Rydahl Andersen added a comment - if you could tell me how we could do that, e.g. a patch then that would help. What about dependent jars ? afaik these needs to be osgi-fied too....and they aren't afaik.
          Hide
          Baptiste MATHUS added a comment -

          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 http://osdir.com/ml/ide.eclipse.equinox.devel/2006-03/msg00097.html for more information).

          Happily enough, a tool has been developed to be able automatically generate those informations: BND, cf. http://www.aqute.biz/Code/Bnd. Btw, one of the samples using BND has been done with hibernate: http://www.aqute.biz/Code/BndHibernate.

          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: http://blog.springsource.com/main/2008/02/18/creating-osgi-bundles/

          Show
          Baptiste MATHUS added a comment - 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 http://osdir.com/ml/ide.eclipse.equinox.devel/2006-03/msg00097.html for more information). Happily enough, a tool has been developed to be able automatically generate those informations: BND, cf. http://www.aqute.biz/Code/Bnd . Btw, one of the samples using BND has been done with hibernate: http://www.aqute.biz/Code/BndHibernate . 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: http://blog.springsource.com/main/2008/02/18/creating-osgi-bundles/
          Hide
          Baptiste MATHUS added a comment -

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

          Show
          Baptiste MATHUS added a comment - Small patch on the hibernate-core pom.xml to use maven-bundle-plugin to package hibernate-core so that it's osgi-compatible.
          Hide
          Max Rydahl Andersen added a comment -

          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 ?

          Show
          Max Rydahl Andersen added a comment - 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 ?
          Hide
          Eric Jain added a comment -

          Isn't Hibernate 4 planning to support OSGi anyway (see http://community.jboss.org/wiki/HibernateCoreMigrationGuide40)? Meanwhile, you could either use SpringSource's (outdated) version of Hibernate, or switch to EclipseLink.

          Show
          Eric Jain added a comment - Isn't Hibernate 4 planning to support OSGi anyway (see http://community.jboss.org/wiki/HibernateCoreMigrationGuide40)? Meanwhile, you could either use SpringSource's (outdated) version of Hibernate, or switch to EclipseLink.
          Hide
          Steve Ebersole added a comment -

          Discussion moved to HHH-7527

          Show
          Steve Ebersole added a comment - Discussion moved to HHH-7527

            People

            • Votes:
              4 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development