Skip to content

[OSGi] Multibindings and AssistedInject JARs need version property for fragment host #1049

Closed

Description

@kenwenzel

The libraries "guice-multibindings" and "guice-assistedinject" are implemented as OSGi fragements for the "com.google.inject" bundle.
If two versions (e.g. 3.0.0 and 4.0.0) of Guice are used within the same OSGi container (Eclipse Equinox) then the following exception occurs:

java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) previously initiated loading for a different type with name "com/google/inject/Binder"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:273)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:586)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:538)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:525)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:325)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:334)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:411)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:361)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:353)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.inject.multibindings.Multibinder.newRealSetBinder(Multibinder.java:176)
at com.google.inject.multibindings.Multibinder.newSetBinder(Multibinder.java:132)

I think this is due to the following line within the MANIFEST.MF of each bundle:

Fragment-Host: com.google.inject

The Fragment-Host should not only specify the host bundle but also its version:

Fragment-Host: com.google.inject;bundle-version=4.0.0

Activity

  1. added a commit that references this issue on Sep 30, 2016
    f75f5e6
  2. added 3 commits that reference this issue on Apr 20, 2023
    ba3fa48
    9c22b5e
    356f6ba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址