title: Eclipse/OSGi class loading issue - java.lang.LinkageError when trying to load a plugin with two versions
body: <p>In my Eclipse runtime, I have the following three plug-ins (file names simplified for better readability):</p>
  
  <ul>
  <li>javax.wsdl.1.4.0.jar</li>
  <li>javax.wsdl.1.5.1.jar</li>
  <li>eclipse.wsdl.jar, which has a version restriction on the dependency: [1.4.0, 1.5.0)</li>
  </ul>
  
  <p>The dependencies of my own plugin look like this:
  eclipse.wsdl
  javax.wsdl : "1.4.0"</p>
  
  <p>When my own plugin tries to use the class WSDLFactory, an error would be thrown:</p>
  
  <pre><code>java.lang.LinkageError: loading constraint violation: loader "org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader@a7b0a7b" previously initiated loading for a different type with name "javax/wsdl/factory/WSDLFactory" defined by loader "org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader@7c647c64"
  </code></pre>
  
  <p>Apparently, my own plug-in loads the 1.5.1 version of WSDLFactory, while eclipse.wsdl loads the 1.4.0 version of WSDLFactory, and this cause the conflict.  If I change the version restriction of my plugin to be [1.4.0, 1.5.1), the code would work just fine.  However, this is unacceptable since my code needs to support Eclipse 3.5 which forces to use javax.wsdl.1.5.1 intead of 1.4.0.</p>
  
  <p>Are there any way to force my code to use the WSDLFactory loaded by eclipse.wsdl instead of trying to load its own?</p>
  
  <p>And if possible at all, is there a way to force loading the lowest version (instead of highest) bundle?</p>
  
  <p><strong>Update</strong>: I tried both Require-Bundle and Import-Package and got different results in dev and release environment. Require-Bundle doesn't work for either one. Import-Package works in the dev environment but not in the release environment.  </p>
  
  <p>My question is, while Require-Bundle would try to load classes that are in the highest version of the plugin, does Import-Package NOT behave like that?</p>
  
  <p>The following are corresponding MANIFEST.MF's:</p>
  
  <p>Require-Bundle:</p>
  
  <pre><code>Manifest-Version: 1.0
  Bundle-ManifestVersion: 2
  Bundle-Name: Test
  Bundle-SymbolicName: wsdl.classloading.test; singleton:=true
  Bundle-Version: 1.0.0.qualifier
  Bundle-Activator: wsdl.classloading.test.Activator
  Require-Bundle: org.eclipse.ui,
   org.eclipse.core.runtime,
   org.eclipse.wst.wsdl;bundle-version="1.1.202",
   javax.wsdl;bundle-version="1.4.0"
  Bundle-RequiredExecutionEnvironment: JavaSE-1.6
  Bundle-ActivationPolicy: lazy
  </code></pre>
  
  <p>Import-Package:</p>
  
  <pre><code>Manifest-Version: 1.0
  Bundle-ManifestVersion: 2
  Bundle-Name: Test
  Bundle-SymbolicName: wsdl.classloading.test; singleton:=true
  Bundle-Version: 1.0.0.qualifier
  Bundle-Activator: wsdl.classloading.test.Activator
  Require-Bundle: org.eclipse.ui,
   org.eclipse.core.runtime,
   org.eclipse.wst.wsdl;bundle-version="1.1.202"
  Bundle-RequiredExecutionEnvironment: JavaSE-1.6
  Bundle-ActivationPolicy: lazy
  Import-Package: javax.wsdl,
   javax.wsdl.factory,
   javax.wsdl.xml
  </code></pre>