{"record":{"id":"3a8a2b11bdd267fa","repo":"pinpoint-apm/pinpoint","slug":"invalid-classloader","errorCode":null,"errorMessage":"invalid ClassLoader","messagePattern":"invalid ClassLoader","errorType":"exception","errorClass":"PinpointException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/URLClassLoaderHandler.java","lineNumber":69,"sourceCode":"\n    public URLClassLoaderHandler(PluginConfig pluginConfig) {\n        this.pluginConfig = Objects.requireNonNull(pluginConfig, \"pluginConfig\");\n    }\n\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public <T> Class<? extends T> injectClass(ClassLoader classLoader, String className) {\n        try {\n            if (classLoader instanceof URLClassLoader) {\n                final URLClassLoader urlClassLoader = (URLClassLoader) classLoader;\n                addPluginURLIfAbsent(urlClassLoader);\n                return (Class<T>) urlClassLoader.loadClass(className);\n            }\n        } catch (ReflectiveOperationException e) {\n            logger.warn(\"Failed to load plugin class {} with classLoader {}\", className, classLoader, e);\n            throw new PinpointException(\"Failed to load plugin class \" + className + \" with classLoader \" + classLoader, e);\n        }\n        throw new PinpointException(\"invalid ClassLoader\");\n    }\n\n    @Override\n    public InputStream getResourceAsStream(ClassLoader targetClassLoader, String internalName) {\n        try {\n            if (targetClassLoader instanceof URLClassLoader) {\n                final URLClassLoader urlClassLoader = (URLClassLoader) targetClassLoader;\n                addPluginURLIfAbsent(urlClassLoader);\n                return targetClassLoader.getResourceAsStream(internalName);\n            }\n        } catch (ReflectiveOperationException e) {\n            logger.warn(\"Failed to load plugin resource as stream {} with classLoader {}\", internalName, targetClassLoader, e);\n            return null;\n        }\n        return null;\n    }\n\n    private void addPluginURLIfAbsent(URLClassLoader classLoader) throws ReflectiveOperationException {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/URLClassLoaderHandler.java#L51-L87","documentation":"PinpointException(\"invalid ClassLoader\") thrown by URLClassLoaderHandler.injectClass when the passed classLoader is not an instance of URLClassLoader. This handler can only inject classes through URLClassLoaders; any other loader type falls through the instanceof check and hits this terminal throw.","triggerScenarios":"injectClass(classLoader, className) called with a classloader that is not a URLClassLoader (e.g. an application server's custom classloader, OSGi loader, or the bootstrap/app loader wrapped differently).","commonSituations":"Running on an app server or framework whose classloader does not extend URLClassLoader (common on modern containers and JDK 9+ where the app classloader is no longer a URLClassLoader), or a mismatch between the classloader strategy selected at agent bootstrap and the loader actually handed to the handler.","solutions":["Verify which ClassLoaderHandler implementation should serve this classloader; ensure the agent's classloader strategy matches (e.g. a non-URL handler for non-URLClassLoaders).","Log/print the classloader's concrete class and check whether it extends URLClassLoader; if not, this handler must not be used.","On JDK 9+, the app classloader is not a URLClassLoader - confirm the Pinpoint version supports the target JDK and classloader type.","If you control the caller, pass the URLClassLoader that actually contains the plugin classes instead of an unrelated loader."],"exampleFix":"// before\nhandler.injectClass(someCustomClassLoader, className); // not a URLClassLoader\n// after\nif (someCustomClassLoader instanceof URLClassLoader) {\n    handler.injectClass(someCustomClassLoader, className);\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean supportsInject(ClassLoader cl) { return cl instanceof URLClassLoader; }","tryCatchPattern":"try { return handler.injectClass(cl, name); } catch (PinpointException e) { if (\"invalid ClassLoader\".equals(e.getMessage())) { /* route to a compatible handler */ } throw e; }","preventionTips":["Check the concrete classloader type before choosing a handler","On JDK 9+ do not assume the app classloader is a URLClassLoader","Log classLoader.getClass().getName() when diagnosing injection failures"],"tags":["classloading","classloader","pinpoint","unsupported"],"backgroundTag":"unsupported-classloader-type","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}