Class SpringBootClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable, LoggableClassLoader

public class SpringBootClassLoader extends CustomURLClassLoader
A JVM-wide singleton ClassLoader that holds the shared Spring Boot / Spring Framework / Spring Security / Tomcat-embedded / Jackson library layer (a directory scan of SystemLocations.libSpringBootShared()), used ONLY by the Spring-Boot-based fat-jar service processes (MCP server, REST V3, GraphQL server - see com.gigaspaces.internal.services.SpringBootServiceFactory) so those services' own fat jars no longer need to each bundle a full private copy of these ~65 dependencies (PIC-6253).

This is deliberately NOT the JVM's root/platform parent classloader, and it is NOT a child of CommonClassLoader (the shared parent used by GSA/GSC/GSM/LUS/TM/ESM's ServiceClassLoader chain, via RioServiceDescriptor). It is a sibling of CommonClassLoader, parented directly on the JVM's system classloader:

             AppCL (system classpath: lib/required[SYSTEM], spring-boot-loader.jar, ...)
         /                                              \
  CommonClassLoader                              SpringBootClassLoader        (this class)
  (used only by GSA/GSC/GSM/LUS/TM/ESM)           (used only by Spring-Boot ServiceFactories)
       |                                        /          |            \
  ServiceClassLoader                    CFCL(MCP)    CFCL(RESTV3)   CFCL(GRAPHQL)
                                             |            |             |
                                      LaunchedClassLoader (BOOT-INF/lib of each fat jar)
Three reasons for this exact placement, not as a child of CommonClassLoader:
  1. Topology independence: in the standalone distribution each Spring Boot service gets its own dedicated JVM (config/gsa/{mcp,restv3,graphql}.xml), where CommonClassLoader is never populated at all; but in Kubernetes, REST V3 can share a JVM with GSM/LUS/ZK/REST (the combined "manager" process), where CommonClassLoader IS populated with Rio platform jars. Parenting on it would make REST V3's effective classpath depend on which topology it happens to run in - exactly the kind of nondeterminism this design must avoid.
  2. CommonClassLoader.getURLs() is overridden to report the current thread's context classloader's URLs (a Jini/RMI codebase-annotation mechanism), not its own - a parent that reports someone else's URLs depending on the calling thread is a poor foundation for an embedded-Tomcat classpath/resource scan.
  3. Minimum delta: today, each Spring-Boot ServiceFactory's ChildFirstURLClassLoader is already parented on the plain system/application classloader (see ServiceFactory.createService() - the context classloader at that point is always the system classloader, since RioServiceDescriptor.create() always restores it in a finally block). Inserting this loader between them is a pure addition of one level, not a topology change.

Content is a directory scan, established once and never mutated afterwards - the shared set is a static build artifact (see xap-tools/xap-spring-boot-shared in xap-premium), unlike CommonClassLoader.addCommonJARs(URL[])'s dynamic, per-service push API. If the shared directory is missing or empty, construction fails loudly rather than silently booting with an empty parent: a silently-empty shared loader reproduces exactly the swallowed-NoClassDefFoundError class of bug this project has already hit once before (see RestV3ServiceFactory's and GsPremiumCommandFactory's comments on externalized snakeyaml/jakarta.annotation-api).

Since:
18.0.0
Author:
Niv Ingberg
  • Method Details

    • getInstance

      public static SpringBootClassLoader getInstance()
      Returns the JVM-wide singleton instance, lazily creating it (and eagerly loading its shared jar set) on first call.