Uploaded image for project: 'Axiom'
  1. Axiom
  2. AXIOM-355

Axiom Causes java.lang.LinkageError Running Under OSGi/Servicemix/Equinox

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 1.2.10
    • None
    • None
    • None
    • Apache Servicemix 4.3 (Fuse distribution), Apache ODE, Equinox

    Description

      When using Apache ODE under Apache Servicemix, Fuse distribution, which uses Equinox as a OSGi container, the Apache ODE code throws a classloader exception (see below....java.lang.LinkageError) when trying to use the javax.xml.stream.util package. The error seems to be related to a partial OSGi "Import-Package" decleration provided by Apache Axiom. To fix, I adjusted the OSGi manifest, and added:

      javax.xml.stream.events,javax.xml.stream.util

      Around/alongside the javax.xml.stream import package statement. This hack was not something I would recommend normal users to have to do--it just illustrates the OSGi packaging problem Axiom has.

      What I think is going on here is that Axiom loads parts of its classes with the OSGi loader when running under Servicemix, which provides the javax.xml.stream package from a supplied package (Stax API), and then the boot loader provides other parts. These two class domains cannot be intermingled.

      Please simply add these two packages listed above to an explicitly declared Import-Package to the maven compile for Axiom. This will fix this nicely. Simply add all three to the maven-bundle-plugin:

      javax.xml.stream,
      javax.xml.stream.events,
      javax.xml.stream.util

      A workaround for this issue can be found at the bottom of this web page, on project Apache ODE: http://ode.apache.org/smx4-osgi-deployment.html. Note the workaround in this case causes the javax.xml.stream to always be loaded from one place, and the OSGi manifest tweaks on Import-Package I suggest above do the same thing (but don't require the user to change the configuration of the container).

      Here is the stacktrace for the error I am receiving:

      Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.stream.util.StreamReaderDelegate.<init>(Ljavax/xml/stream/XMLStreamReader;)V" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/apache/axiom/om/impl/builder/SafeXMLStreamReader, and the class loader (instance of <bootloader>) for resolved class, javax/xml/stream/util/StreamReaderDelegate, have different Class objects for the type javax/xml/stream/XMLStreamReader used in the signature
      at org.apache.axiom.om.impl.builder.SafeXMLStreamReader.<init>(SafeXMLStreamReader.java:62)
      at org.apache.axiom.om.impl.builder.StAXBuilder.initParser(StAXBuilder.java:151)
      at org.apache.axiom.om.impl.builder.StAXBuilder.<init>(StAXBuilder.java:128)
      at org.apache.axiom.om.impl.builder.StAXBuilder.<init>(StAXBuilder.java:160)
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.<init>(StAXOMBuilder.java:130)
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.<init>(StAXOMBuilder.java:146)
      at org.apache.ode.il.DynamicService.convertToOM(DynamicService.java:159)
      at org.apache.ode.il.DynamicService.invoke(DynamicService.java:78)
      at org.apache.ode.jbi.DynamicMessageExchangeProcessor.invoke(DynamicMessageExchangeProcessor.java:61)
      at org.apache.ode.jbi.BaseMessageExchangeProcessor.onJbiMessageExchange(BaseMessageExchangeProcessor.java:83)
      ... 8 more

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kwesterfeld Kurt Westerfeld
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: