Search code examples
javawildflyclassloader

Instantiating a deployment's class from a global library in Wildfly


In my Wildfly environment I have a global library that is used by disparate application deployments. Those disparate application deployments include customizations for that global library.

However, that global library retains responsibility for actually instantiating those customizations. I provide the class name that it needs and then it instantiates them via its own classloader upon initialization.

However, when I do that it throws a ClassNotFoundException. Is there a way to "notify" the global library classloader that the package does, indeed, exist, or is my only path forward to customize the class loader in some way?


Solution

  • Thanks to James Perkins for the help. It seems as though the most workable solution (I don't know if it's best) was to move the functional libraries, which constituted a fraction of the bulk of the deployment, into the WAR, but to place the model libraries in the general lib folder. The model libraries don't need to refer back to deployed WAR so they can be as global as they need to be. By placing the functional libraries in the WAR they are able to see the customizations that I made.