Using Libraries for Pluggable Frameworks
Many libraries provide pluggable architectures via Service Provider Interfaces (SPI). The Container provides special support for JAXB/JAXP to simplify working with XML processing. Using other libraries usually requires some manual setup in the application package.
Troubleshooting and Configuring the Application
Libraries for pluggable frameworks rely on loading classes dynamically at runtime, usually via
Class.forName("…"). If the package of the class that is loaded is not
imported by our user bundle, this will result in the following error:
java.lang.ClassNotFoundException: com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi not found by my-bundle  at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)The example above is from using the Image I/O framework. In this case, notice that the missing class is from a
com.sunpackage, which is available in the SDK.
Importing the Missing Package
ClassNotFoundException means that the bundle is not importing the package.
will usually not have added an import since the class is only
referred to from a string in a
Hence, add an explicit
importPackage in the bundle's pom.xml:
<build> <plugins> <plugin> <groupId>com.yahoo.vespa</groupId> <artifactId>bundle-plugin</artifactId> ... <configuration> <importPackage>com.sun.imageio.plugins.jpeg</importPackage> ... </configuration> </plugin> </plugins> </build>The
importPackageconfiguration option takes a comma-separated list of packages. Adding multiple
importPackageelements in pom.xml means that only one of them will take effect.
Exporting the Missing Package from the Container
As mentioned, the missing package in this example is part of the SDK.
In these cases, we must tell the Container to export the missing package.
When running in cluster mode
this is done in
<container version="1.0"> <config name="search.config.qr-start"> <jdisc> <export_packages>com.sun.imageio.plugins.jpeg</export_packages> </jdisc> </config> ... </container>