1

I need one of Apache libraries (axis-jaxrpc) in my OSGi bundle, but it's kind of defective as its jar contains a class from java built-ins (javax.xml.namespace.QName). I cannot replace it with any other alternative - it's a side-dependency for another dependency for ...... you know how this goes :)

The problem is that whenever I bundle the package and fire it up it starts up just fine. But if I touch any functionality related to jaxrpc I get a LinkageError claiming that QName has already been loaded by <bootloader>.

I managed to explode jaxrpc jar into my bundle jar and remove javax.namespace directory manually (i.e. edit the bundle jar contents) before launching the app. That did the trick - I no longer get the LinkageError.

Now the question is... How do I deal with this situation in a non-sado-maso way and exclude the offending class/package from the embedded jar file?

POM snippets:

dependencies:

<dependency>
    <groupId>org.apache.axis</groupId>
    <artifactId>axis</artifactId>
    <version>1.4</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.apache.axis</groupId>
    <artifactId>axis-jaxrpc</artifactId>
    <version>1.4</version>
    <scope>provided</scope>
</dependency>

bundle-plugin:

<plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.6</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Export-Package>
                        /* application packages only */
                    </Export-Package>
                    <Private-Package>
                        /* application packages only */
                    </Private-Package>
                    <DynamicImport-Package>
                        *
                    </DynamicImport-Package>
                    <Import-Package></Import-Package>
                    <Include-Resource>
                        {maven-resources},target/classes/rebel.xml
                    </Include-Resource>
                    <Embed-Dependency>
                        /* other dependencies */
                        axis,
                        axis-jaxrpc;inline=true,
                        commons-discovery,
                        commons-logging
                    </Embed-Dependency>
                </instructions>
            </configuration>
        </plugin>

To rephrase... Is there any way do do smth like this:

<Embed-Dependency>
    axis-jaxrpc;inline=true;exclude=javax.namespace.QName
</Embed-Dependency>

EDIT:

exception for clarity:

Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.axis.message.MessageElement.getChildElements(Ljavax/xml/namespace/QName;)Ljava/util/Iterator;" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of the current class, org/apache/axis/message/MessageElement, and the class loader (instance of ) for interface javax/xml/soap/SOAPElement

netikras
  • 422
  • 4
  • 12

1 Answers1

1

Remove axis-jaxrpc from <Embed-Dependency> and add the packages from axis-jaxrpc that you care about to <Private-Package> section - those will be embedded in your bundle. You may need to do the same for the packages axis-jaxrpc depends on or add the respective dependency bundles to <Embed-Dependency>

Milen Dyankov
  • 2,972
  • 14
  • 25