Aspose.Words NamespaceContext not found when used as OSGI

After “overcoming” with a workaround the issue that (probably) the classifier produces making it unable to resolve the aspose dependency: Aspose.Words as OSGI . Dependency cannot be resolved

i was able to start my bundle which includes Aspose.Words dependency on Apache Karaf (4.0.9). I declared aspose in my features.xml in the following way:

<bundle>wrap:mvn:com.aspose/aspose-words/18.6-jdk16$Bundle-SymbolicName=com.aspose.words&amp;Export-Package=com.aspose.words.*;version=18.6&amp;overwrite=merge</bundle>

Unfortunately when i try to convert a document, i get the following error:

java.lang.NoClassDefFoundError: javax/xml/namespace/NamespaceContext
at asposewobfuscated.zzP.(Unknown Source)
at asposewobfuscated.zzP.(Unknown Source)
at com.aspose.words.zz7R.zz8(Unknown Source)
at com.aspose.words.zz18.zzZVO(Unknown Source)
at com.aspose.words.zz18.zzY(Unknown Source)
at com.aspose.words.Document.zzY(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)

The headers for aspose on karaf resolve following:

Aspose.Words for Java (155)

Application-Name = Aspose.Words for Java
Bnd-LastModified = 1530621699281
Codebase = *
Created-By = 1.8.0_91 (Oracle Corporation)
Generated-By-Ops4j-Pax-From = wrap:file:/C:/Users/steph/.m2/repository/com/aspose/aspose-words/18.6-jdk16/aspose-words-18.6-jdk16.jar$Bundle-SymbolicName=com.aspose.words&Export-Package=com.aspose.words.*;version=18.6&overwrite=merge
Implementation-Title = Aspose.Words for Java
Implementation-Vendor = Aspose Pty Ltd
Implementation-Version = 18.6
Manifest-Version = 1.0
Permissions = all-permissions
Release-Date = 2018.06.01
Specification-Title = Aspose.Words for Java
Specification-Vendor = Aspose Pty Ltd
Specification-Version = 18.6
Tool = Bnd-2.3.0.201405100607

Bundle-ManifestVersion = 2
Bundle-Name = Aspose.Words for Java
Bundle-SymbolicName = com.aspose.words
Bundle-Version = 18.6

Require-Capability =
osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=1.6))

Export-Package =
com.aspose.words;uses:=“com.aspose.words.net.System.Data,com.aspose.words.ref,javax.print.attribute”;version=18.6,
com.aspose.words.net.System;version=18.6,
com.aspose.words.net.System.Data;uses:=com.aspose.words.net.System.Data.Common;version=18.6,
com.aspose.words.net.System.Data.Common;uses:=com.aspose.words.net.System.Data;version=18.6,
com.aspose.words.ref;version=18.6
Import-Package =
javax.crypto;resolution:=optional,
javax.crypto.spec;resolution:=optional,
javax.imageio;resolution:=optional,
javax.imageio.metadata;resolution:=optional,
javax.imageio.spi;resolution:=optional,
javax.imageio.stream;resolution:=optional,
javax.print;resolution:=optional,
javax.print.attribute;resolution:=optional,
javax.print.attribute.standard;resolution:=optional,
javax.swing;resolution:=optional,
javax.xml.parsers;resolution:=optional,
javax.xml.transform;resolution:=optional,
javax.xml.transform.dom;resolution:=optional,
javax.xml.transform.stream;resolution:=optional,
javax.xml.xpath;resolution:=optional,
org.w3c.dom;resolution:=optional,
org.xml.sax;resolution:=optional,
javax.swing.text;resolution:=optional
Private-Package =
asposewobfuscated,
resources,
resources.OleIcons,
resources.PageBorderArt

Is there something extra i need to export in order Aspose to find the NamespaceContext class ? Do i need to wrap another required dependency by Aspose.Words ?

@ssch,

Thanks for your inquiry. We have logged this problem in our issue tracking system as WORDSJAVA-808. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

I was able to resolve the issue. I had to manually import some missing classes. The following did the trick:

<bundle>wrap:mvn:com.aspose/aspose-words/18.6-jdk16$Bundle-SymbolicName=com.aspose.words&amp;Import-Package=javax.xml.*,javax.print.*,org.w3c.*,javax.imageio.*&amp;overwrite=merge</bundle>

I don’t know if that is an issue of Aspose.Words or Karaf though.

@ssch,

Thanks for your feedback. It is nice to hear from you that you have solved your issue. You can use Aspose.Words for Java where Java is installed. There is no issue using Aspose.Words for Java in OSGI bundle. Probably, the issue you were facing is due to OSGI project setting. We have closed WORDSJAVA-808 issue. Please let us know if you have any query about Aspose.Words.