{"record":{"id":"be900c3a9d7c38a3","repo":"pinpoint-apm/pinpoint","slug":"failed-to-load-plugin-resource-as-stream-with-c-be900c","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/PluginClassInjector.java","lineNumber":99,"sourceCode":"        }\n    }\n\n    @Override\n    public InputStream getResourceAsStream(ClassLoader targetClassLoader, String internalName) {\n        try {\n            if (bootstrapCore.isBootstrapPackageByInternalName(internalName)) {\n                return bootstrapCore.openStream(internalName);\n            }\n            if (targetClassLoader == null) {\n                return bootstrapClassLoaderHandler.getResourceAsStream(null, internalName);\n            } else if (targetClassLoader instanceof URLClassLoader) {\n                final URLClassLoader urlClassLoader = (URLClassLoader) targetClassLoader;\n                return urlClassLoaderHandler.getResourceAsStream(urlClassLoader, internalName);\n            } else {\n                return plainClassLoaderHandler.getResourceAsStream(targetClassLoader, internalName);\n            }\n        } catch (Throwable e) {\n             logger.warn(\"Failed to load plugin resource as stream {} with classLoader {}\", internalName, targetClassLoader, e);\n            return null;\n        }\n    }\n}","sourceCodeStart":81,"sourceCodeEnd":103,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/PluginClassInjector.java#L81-L103","documentation":"PluginClassInjector.getResourceAsStream fetches a plugin class's bytecode stream via the URL or plain handler. Any Throwable during routing or lookup is logged with this warn and null is returned; the error is deliberately swallowed so instrumentation can degrade instead of crashing. Null means the resource stream is unavailable.","triggerScenarios":"Any Throwable thrown by urlClassLoaderHandler.getResourceAsStream (e.g. ClassCastException when the loader is not a URLClassLoader) or plainClassLoaderHandler.getResourceAsStream while resolving internalName.","commonSituations":"Non-URLClassLoader loaders incorrectly routed to the URL handler; closed webapp classloaders after redeploy; unreadable plugin jar; wrong internalName format.","solutions":["Check the exception stack trace attached to this warn for the true cause.","Fix loader routing so only URLClassLoaders reach urlClassLoaderHandler.","Validate internalName (package/path + \".class\") and that the resource exists in the plugin jar.","Ensure call sites null-check the returned stream before reading."],"exampleFix":"// before\nbyte[] bytes = IOUtils.toByteArray(injector.getResourceAsStream(targetClassLoader, internalName));\n// after\nInputStream in = injector.getResourceAsStream(targetClassLoader, internalName);\nif (in == null) { return null; }\nbyte[] bytes = IOUtils.toByteArray(in);","handlingStrategy":"fallback","validationCode":"if (targetClassLoader instanceof URLClassLoader) { /* url handler path */ } else { /* plain handler path */ }","typeGuard":"static InputStream safeGetResource(PluginClassInjector injector, ClassLoader cl, String internalName) {\n    InputStream in = injector.getResourceAsStream(cl, internalName);\n    return in != null ? in : cl.getResourceAsStream(internalName);\n}","tryCatchPattern":"InputStream in = injector.getResourceAsStream(cl, internalName);\nif (in == null) { log.warn(\"resource {} unavailable\", internalName); return null; }","preventionTips":["Null-check the stream before reading","Only route URLClassLoaders to the URL handler","Use correct internalName format (path/Foo.class)","Avoid lookups on closed/redeployed classloaders"],"tags":["classloader","plugin","resource","io"],"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"}