Classes in Classpath interfering with OSGi packages

I am writing an OSGi bundle, let it B to be deployed in an existing application. The package will need access to the L library (namely JasperReport), version V2.

Such a library is in the application's classpath not as an OSGi package, but with a version V1 < V2

.

I've tried two scenarios:

  • with a copy of the library L.jar

    in my package B.jar

    , and include it in Bundle-ClassPath

    ;
  • creating an OSGi-fied version L-osgi.jar

    in a library with bnd

    , indicating in all Export-Package

    that the exported version is V2, deploying it along with my own package, and in the latter Import-Package

    ask specifically for the V2 version.

I expected both of these methods to work because I expect each packet to only see packets specifically required in the header Import-Package

in MANIFEST

.

However, I am getting this error:

Caused by: net.sf.jasperreports.engine.JRRuntimeException: Class net.sf.jasperreports.extensions.DefaultExtensionsRegistry does not implement/extend net.sf.jasperreports.extensions.ExtensionsRegistry

      

which feels like this, using one copy of the library to get the base class / interface and another copy to subclass (by the way, this happens even if I install the same version of the library).

I will try the Import-Package

version of the library provided by the app and do it with this old version, but why is this happening? Can I prevent this?

+3


source to share





All Articles