Linkage error when using JAXB in plugins

XMLWordPrintable

    • Type: Bug
    • Resolution: Timed out
    • Priority: Medium
    • N/A
    • Affects Version/s: 2.4-M3
    • Component/s: Integrations
    • Environment:

      JAVA 1.6 ONLY

    • Severity 2 - Major

      When using JAXB in plugins a LinkageError occurs:
      ava.lang.LinkageError: loader constraint violation: when resolving overridden method "com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Ljavax/xml/stream/XMLStreamReader;)Ljava/lang/Object;" the class loader (instance of org/apache/felix/framework/ModuleImpl$ModuleClassLoader) of the current class, com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type javax/xml/stream/XMLStreamReader used in the signature
      [java] at com.atlassian.applinks.core.rest.client.ManifestRetriever.createRequestAndRetrieveManifest(ManifestRetriever.java:124)

      I investigated this issue and my conclusion is:

      This error happens only using Java 1.6 which ships with JAXB.
      The plugins framework will enforce to export three JAXB packages (javax.xml.stream, javax.xml.stream.events javax.xml.stream.uti) from the host container as defined in jdk6-packages.txt.
      This leads to a potential class loading error. When running java 1.6 classes of these packages are also exported to OSGI from the rest plugin.
      I managed to fix this problem by:

      1. Modifying jdk6-packages.txt not to enforce the export of javax.xml.stream, javax.xml.stream.events javax.xml.stream.util, because they are provided by the rest plugin
      2. Modifying FisheyePackageScannerConfiguration which included by default "javax.xml.bind*","javax.*", to be exported to osgi.

      Now only the rest plugin exports JAXB classes and the LinkageError disappeared.

        1. CRUC-3916.path
          0.9 kB
          Felix Schmitz [Atlassian]

            Assignee:
            Unassigned
            Reporter:
            Felix Schmitz [Atlassian]
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: