{"record":{"id":"8b5d53e75db7551c","repo":"pinpoint-apm/pinpoint","slug":"failed-to-load-plugin-resource-as-stream-with-c-8b5d53","errorCode":null,"errorMessage":"Failed to load plugin resource as stream {} with classLoader {}","messagePattern":"Failed to load plugin resource as stream (.+?) with classLoader (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/URLClassLoaderHandler.java","lineNumber":81,"sourceCode":"                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 {\n        final URL[] urls = classLoader.getURLs();\n        if (urls != null) {\n            final boolean hasPluginJar = hasPluginJar(urls);\n            if (!hasPluginJar) {\n                if (isDebug) {\n                    logger.debug(\"add Jar:{}\", pluginConfig.getPluginJarURLExternalForm());\n                }\n                ADD_URL.invoke(classLoader, pluginConfig.getPluginURL());\n            }\n        }\n    }\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/URLClassLoaderHandler.java#L63-L99","documentation":"Not a thrown error but a warn-level log in URLClassLoaderHandler.getResourceAsStream: when loading a plugin resource (e.g. a .class bytecode stream) from the target URLClassLoader fails with a ReflectiveOperationException, the handler logs this message and returns null. Callers treat null as 'resource unavailable' and instrumentation falls back or aborts gracefully.","triggerScenarios":"getResourceAsStream(internalName, targetClassLoader) is called, the target loader is a URLClassLoader, and the reflective URL injection (addPluginURLIfAbsent) or resource lookup throws - typically because the resource does not exist in the plugin jar or reflective access is denied (JDK 9+ module restrictions).","commonSituations":"JDK 9+ strong encapsulation blocking reflective access to URLClassLoader.addURL; plugin jar missing the resource path; internalName mismatch (slashes vs dots); plugin not deployed.","solutions":["Check JVM output for reflective-access warnings; add --add-opens java.base/java.net=ALL-UNNAMED on JDK 9+ if needed","Verify the resource (e.g. class file path in slash form) exists inside the plugin jar","Confirm the plugin jar is in the agent's plugin directory","Upgrade Pinpoint agent to a version with a classloader handler that supports JDK 9+"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// check resource presence in the plugin jar before requesting it\nString path = internalName.replace('.', '/') + \".class\";\nboolean exists = new java.util.jar.JarFile(pluginJar).getJarEntry(path) != null;","typeGuard":null,"tryCatchPattern":"java.io.InputStream in = handler.getResourceAsStream(internalName, targetClassLoader);\nif (in == null) {\n    logger.warn(\"Plugin resource {} unavailable; falling back to non-instrumented path\", internalName);\n    return originalBehavior();\n}","preventionTips":["Treat null return as expected outcome, not an exceptional crash","Use slash-separated internal names when looking up resources","Add --add-opens java.base/java.net=ALL-UNNAMED on JDK 9+ if reflective URL injection is blocked","Ensure plugin jars are deployed to the agent plugin directory"],"tags":["classloading","plugins","resources"],"backgroundTag":"resource-not-found","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"}