Search code examples
websphereosgishared-libraries

Load Classes from WAS shared library in OSGi bundle


Is it possible to use classes that are in a websphere application server shared library from within an OSGi bundle?

I did some research and found this http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/topic/com.ibm.iea.was_v8/was/8.5/ProgrammingModel/WAS85_LP_Class_Loading.pdf which indicates that it ispossible to load OSGi classes from standard java, however, there is no indication whether the opposite is possible. Any help would be appreciated!


Solution

  • No, it is not possible to use a Java EE shared library from an OSGi application, but you can use a bundle repository to share binaries across OSGi applications.

    The document you linked is primarily discussing Java EE applications in the Liberty Profile runtime:

    The class loader configuration is only valid for Java EE applications. If it is provided for an OSGi application, it is ignored.

    ...

    Since OSGi allows applications to specify the versions of packages to be imported, once again this coarser level of control is only needed for Java EE applications.

    Any mention of OSGi class loading is pointing out that Java EE applications have visibility to product classes that are loaded by an OSGi runtime. There is a brief mention of bundle repositories for OSGi applications:

    Note that this library definition is for use by Java EE applications. There is a separate facility known as the bundle repository for configuring additional bundles to be used by OSGi applications.