Visibility of classes in a web-app to dependent modules

Solution Unverified - Updated -

Issue

  • We have been having some problems with class loading via Spring.So the purpose of this ticket is for me to understand how class visibility between a deployed application and its modules works. I've read quite a bit of documentation but I'm still unclear exactly how it work so would appreciate some more detail.

  • This is in the context of WAR applications, not EARs

  • Let's say a web-app deployed as a WAR file which has a dependency on Module A, which in turn has a dependency on module B (i.e app -> A -> B) . There is no declared dependency in my app for Module B.

  • It seems that : The code in app will be able to access classes in module A - the code in Module A will be able to access classes on apps WEB-INF/classes. We have proved this already by the fact that Spring module can dependency injection to a CXF application using the instructions here How do I configure CXF via Spring in EAP 6?. So,

    • Will the code in my app be able to access classes (or other assets on the class path) in module 'B' or will module B need to be declared as an explicit dependency in the app
    • will the code in Module 'B' have any visibility of classes (or other assets on the classpath) within my application's web-inf classes structure. This is particularly relevant if it uses something along the lines of this.getClass().getClassLoader()) to load something that's on the classpath in web app
  • Is there a way we can indicate to JBoss that all required modules for a deployment are to be loaded into the same class loader as the deployment itself , so that any cross-dependencies are resolved within a single class loader ?

  • So, any documentation regarding 'best practice' for Spring in JBoss EAP 6 , particularly in the context of CXF applications ? Doing it via application context seems to be working (so far) but doesn't feel very elegant.

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.3.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.