This page describes how to work with third-party Java libraries in NetKernel modules.
If requests using a third-party library class stay within a single NK module, there is no pronlem, because all of the endpoints in the module use the same Java classloader.
But, if the endpoints can be reached by other NK modules, you have to be careful about ensuring those calling modules have access to the SAME COPY of the representation class in their classloader. Otherwise, when calling endpoints try to
source one of your endpoints, the Java runtime will complain “Cannot cast Foo into Foo” errors. That is because Java cannot cast objects of the same type between two classloaders .. as far as Java is concerned, they are two different types.
The answer is to ensure that all spaces that contain endpoints that use the same third party library class as a request representation (either sending or receiving) share the same copy of the class definition. This can be done in several ways: