1. glassfish
  2. GLASSFISH-17899

hk2/class-model.jar contains classes which are also present in hk2/auto-depends.jar with different versions causing osgi resolver error


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.1.2_dev
    • Component/s: other
    • Labels:


      See stack trace below which says that class-model classes are found in two different bundles with different package versions. That results in a constraint violation.
      [exec] Launching GlassFish on Felix platform
      [exec] Completed shutdown of GlassFish runtime
      [exec] Exception in thread "main" java.lang.reflect.InvocationTargetException
      [exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [exec] at sun.reflect.NativeMethodAccessorImpl.invoke(
      [exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      [exec] at java.lang.reflect.Method.invoke(
      [exec] at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(
      [exec] at com.sun.enterprise.glassfish.bootstrap.ASMain.main(
      [exec] Caused by: com.sun.enterprise.module.ResolveError: Failed to start Bundle Id [248] State [INSTALLED] [org.glassfish.main.core.kernel(Kernel Classes):3.1.2.SNAPSHOT]
      [exec] at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.start(
      [exec] at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$2$1$1.loadClass(
      [exec] at com.sun.hk2.component.LazyInhabitant.loadClass(
      [exec] at com.sun.hk2.component.LazyInhabitant.type(
      [exec] at org.jvnet.hk2.component.Habitat$SelfListener.inhabitantIndexChanged(
      [exec] at org.jvnet.hk2.component.Habitat$3.inhabitantChanged(
      [exec] at org.jvnet.hk2.component.Habitat$
      [exec] at org.jvnet.hk2.component.SameThreadExecutor.execute(
      [exec] at org.jvnet.hk2.component.Habitat.doNotify(
      [exec] at org.jvnet.hk2.component.Habitat.notify(
      [exec] at org.jvnet.hk2.component.Habitat.notify(
      [exec] at org.jvnet.hk2.component.Habitat.addIndex(
      [exec] at org.jvnet.hk2.component.Habitat.addIndex(
      [exec] at com.sun.hk2.component.InhabitantsParser.addIndex(
      [exec] at com.sun.hk2.component.InhabitantsParser.add(
      [exec] at com.sun.hk2.component.InhabitantsParser.parse(
      [exec] at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.parseInhabitants(
      [exec] at org.jvnet.hk2.osgiadapter.OSGiModulesRegistryImpl.parseInhabitants(
      [exec] at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createHabitat(
      [exec] at com.sun.enterprise.module.bootstrap.Main.createHabitat(
      [exec] at org.jvnet.hk2.osgiadapter.HK2Main.createHabitat(
      [exec] at com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime.newGlassFish(
      [exec] at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(
      [exec] ... 6 more
      [exec] Caused by: org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve bundle revision org.glassfish.main.core.kernel [248.0] because it is exposed to package 'org.glassfish.hk2.classmodel.reflect.util' from bundle revisions [221.0] and org.glassfish.hk2.class-model [5.0] via two dependency chains.
      [exec] Chain 1:
      [exec] org.glassfish.main.core.kernel [248.0]
      [exec] import: (&(osgi.wiring.package=org.glassfish.hk2.classmodel.reflect.util)(version>=1.0.0))
      [exec] |
      [exec] export: osgi.wiring.package=org.glassfish.hk2.classmodel.reflect.util
      [exec] [221.0]
      [exec] Chain 2:
      [exec] org.glassfish.main.core.kernel [248.0]
      [exec] import: (&(osgi.wiring.package=org.jvnet.hk2.config)(version>=1.0.0))
      [exec] |
      [exec] export: osgi.wiring.package=org.jvnet.hk2.config; uses:=org.glassfish.hk2.classmodel.reflect
      [exec] org.glassfish.hk2.config [112.0]
      [exec] import: (&(osgi.wiring.package=org.glassfish.hk2.classmodel.reflect)(version>=1.1.0))
      [exec] |
      [exec] export: osgi.wiring.package=org.glassfish.hk2.classmodel.reflect; uses:=org.glassfish.hk2.classmodel.reflect.util
      [exec] export: osgi.wiring.package=org.glassfish.hk2.classmodel.reflect.util
      [exec] org.glassfish.hk2.class-model [5.0]
      [exec] at org.apache.felix.framework.Felix.resolveBundleRevision(
      [exec] at org.apache.felix.framework.Felix.startBundle(
      [exec] at org.apache.felix.framework.BundleImpl.start(
      [exec] at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.start(
      [exec] ... 28 more

      There are two solutions:
      I don't know who has changed hk2/auto-depends, but it bundles class-model and tiger_type classes. Although glassfish-hk2 packager is coded to exclude tiger_types.jar, it does not exclude class-model.jar. So, class-model.jar is also present in every distro that contains hk2. The issue is not this duplication of classes in two jars, the real problem is class-model.jar does not export the packages with a version unlike auto-depends.jar. It is perhaps an oversight by whoever added class-model module. So, we are some times facing issues in OSGi package resolution as it is thinking them as distinct packages. We have two ways to solve it:

      1) stop distributing class-model.jar in distro and optionally fix class-model.jar to export with proper version.
      2) stop repackaging classes in auto-depends.jar and fix class-model.jar to export with proper version.

      #1 is preferable as it avoids one extra module.

        Issue Links


          Sanjeeb Sahoo added a comment -

          svn details:
          3.1.2 branch: r51283

          This does not have to be forward ported to trunk, as trunk uses a different version of HK2 which does not have the duplicate package issue.

          Sanjeeb Sahoo added a comment - svn details: 3.1.2 branch: r51283 This does not have to be forward ported to trunk, as trunk uses a different version of HK2 which does not have the duplicate package issue.


            • Assignee:
              Sanjeeb Sahoo
              Sanjeeb Sahoo
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: