pinpoint-apm/pinpoint · warning
Failed to load plugin resource as stream {} with classLoader
Error message
Failed to load plugin resource as stream {} with classLoader {} What it means
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.
Source
Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/PlainClassLoaderHandler.java:105
try {
final String name = JavaAssistUtils.jvmNameToJavaName(internalName);
if (!isPluginPackage(name, targetClassLoader)) {
return targetClassLoader.getResourceAsStream(internalName);
}
getClassLoaderAttachment(targetClassLoader, internalName);
final InputStream inputStream = getPluginInputStream(internalName);
if (inputStream != null) {
return inputStream;
}
if (logger.isInfoEnabled()) {
logger.info("can not find resource : {} {} ", internalName, pluginConfig.getPluginJarURLExternalForm());
}
// fallback
return targetClassLoader.getResourceAsStream(internalName);
} catch (Exception e) {
logger.warn("Failed to load plugin resource as stream {} with classLoader {}", internalName, targetClassLoader, e);
return null;
}
}
private boolean isPluginPackage(String className, ClassLoader classLoader) {
return pluginConfig.getPluginPackageFilter().accept(className, classLoader);
}
private boolean meetsRequirement(String className, ClassLoader classLoader) {
return pluginConfig.getPluginPackageRequirementFilter().accept(className, classLoader);
}
private Class<?> injectClass0(ClassLoader classLoader, String className) throws IllegalArgumentException {
if (isDebug) {
logger.debug("Inject class className:{} cl:{}", className, classLoader);
}
final String pluginJarPath = pluginConfig.getPluginJarURLExternalForm();
final ClassLoaderAttachment attachment = getClassLoaderAttachment(classLoader, pluginJarPath);View on GitHub (pinned to 744c3d3075)
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.
Example fix
// before byte[] bytes = IOUtils.toByteArray(injector.getResourceAsStream(cl, internalName)); // after InputStream in = injector.getResourceAsStream(cl, internalName); byte[] bytes = in == null ? null : IOUtils.toByteArray(in);
Defensive patterns
Strategy: fallback
Validate before calling
if (internalName == null || !internalName.endsWith(".class")) { throw new IllegalArgumentException("bad internalName: " + internalName); } Try / catch
InputStream in = handler.getResourceAsStream(cl, internalName);
if (in == null) { return fallbackStream(internalName); } // e.g. targetClassLoader.getResourceAsStream Prevention
- 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
When it happens
Trigger: Any exception thrown while resolving the plugin config or calling targetClassLoader.getResourceAsStream(internalName) — I/O errors, security exceptions, malformed internalName, or classloader state problems.
Common situations: Resource name format wrong (must be internal name + ".class"); classloader closed (webapp redeploy); plugin jar unreadable; security manager restrictions.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Failed to load plugin resource as stream {} with classLoader
- Failed to load plugin resource as stream {} with classLoader
- IOException parsing
- Error opening stream :
- not found Caused by:
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/05e28d614b9df7bc.
Report an issue: GitHub.