{"record":{"id":"05e28d614b9df7bc","repo":"pinpoint-apm/pinpoint","slug":"failed-to-load-plugin-resource-as-stream-with-c-05e28d","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/PlainClassLoaderHandler.java","lineNumber":105,"sourceCode":"        try {\n            final String name = JavaAssistUtils.jvmNameToJavaName(internalName);\n            if (!isPluginPackage(name, targetClassLoader)) {\n                return targetClassLoader.getResourceAsStream(internalName);\n            }\n\n            getClassLoaderAttachment(targetClassLoader, internalName);\n            final InputStream inputStream = getPluginInputStream(internalName);\n            if (inputStream != null) {\n                return inputStream;\n            }\n\n            if (logger.isInfoEnabled()) {\n                logger.info(\"can not find resource : {} {} \", internalName, pluginConfig.getPluginJarURLExternalForm());\n            }\n            // fallback\n            return targetClassLoader.getResourceAsStream(internalName);\n        } catch (Exception e) {\n            logger.warn(\"Failed to load plugin resource as stream {} with classLoader {}\", internalName, targetClassLoader, e);\n            return null;\n        }\n    }\n\n    private boolean isPluginPackage(String className, ClassLoader classLoader) {\n        return pluginConfig.getPluginPackageFilter().accept(className, classLoader);\n    }\n\n    private boolean meetsRequirement(String className, ClassLoader classLoader) {\n        return pluginConfig.getPluginPackageRequirementFilter().accept(className, classLoader);\n    }\n\n    private Class<?> injectClass0(ClassLoader classLoader, String className) throws IllegalArgumentException {\n        if (isDebug) {\n            logger.debug(\"Inject class className:{} cl:{}\", className, classLoader);\n        }\n        final String pluginJarPath = pluginConfig.getPluginJarURLExternalForm();\n        final ClassLoaderAttachment attachment = getClassLoaderAttachment(classLoader, pluginJarPath);","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/PlainClassLoaderHandler.java#L87-L123","documentation":"PlainClassLoaderHandler.getResourceAsStream fetches the bytecode stream of a plugin class resource from the target classloader (with a plugin-jar fallback). If the lookup throws any Exception, the handler logs this warn and returns null instead of propagating. A null return means the resource could not be loaded, not necessarily that it does not exist.","triggerScenarios":"Any exception thrown while resolving the plugin config or calling targetClassLoader.getResourceAsStream(internalName) — I/O errors, security exceptions, malformed internalName, or classloader state problems.","commonSituations":"Resource name format wrong (must be internal name + \".class\"); classloader closed (webapp redeploy); plugin jar unreadable; security manager restrictions.","solutions":["Read the attached exception stack trace for the underlying cause.","Confirm internalName format (e.g. com/example/Foo.class) and that the resource is packaged in the plugin jar.","Handle the null return at the call site before using the stream.","If the 'can not find resource' info log precedes it, verify the plugin jar URL is correct and accessible."],"exampleFix":"// before\nbyte[] bytes = IOUtils.toByteArray(injector.getResourceAsStream(cl, internalName));\n// after\nInputStream in = injector.getResourceAsStream(cl, internalName);\nbyte[] bytes = in == null ? null : IOUtils.toByteArray(in);","handlingStrategy":"fallback","validationCode":"if (internalName == null || !internalName.endsWith(\".class\")) { throw new IllegalArgumentException(\"bad internalName: \" + internalName); }","typeGuard":null,"tryCatchPattern":"InputStream in = handler.getResourceAsStream(cl, internalName);\nif (in == null) { return fallbackStream(internalName); } // e.g. targetClassLoader.getResourceAsStream","preventionTips":["Null-check the returned stream before reading","Verify the resource exists in the plugin jar","Watch for 'can not find resource' info logs pointing at wrong jar URLs","Avoid classloader lookups after webapp undeploy"],"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"}