With module visibility set, each piece of the EJB is given
a separate classloader when more than one EJB shares dependencies. When a
single EJB uses the dependencies, then the EJB classloader loads the jars.
The pieces are the EJB itself and the jars that it is dependent upon,
which are called helpers. When there are multiple classloaders involved,
these classloaders are visible in a hierarchical way. The EJB classloader
is able to see the classes loaded by the helper classloaders. However,
this only works at one level. If a helper jar has a dependency on another
jar, it will not be able to be loaded because the helper classloaders do
not have visibility of each other.
One solution is to use Application Visibility, which uses a single
classloader for the application. The EJB classes and the helper classes
will be visible to every class in the application.
Another solution is use Module Visibility and to build the helper jars
with no other dependencies among themselves. At runtime, the EJB will not
have visibility of the classes in the Web application.
|