{"record":{"id":"47c60b7a2abfff1e","repo":"pinpoint-apm/pinpoint","slug":"invoke-fail-caused-by","errorCode":null,"errorMessage":" invoke fail Caused by:","messagePattern":" invoke fail Caused by:","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"agent-module/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/classloader/DynamicClassLoaderFactory.java","lineNumber":51,"sourceCode":"\n\n    private static Constructor<? extends ClassLoader> getConstructor(String classLoaderName, ClassLoader classLoader) {\n        try {\n            final Class<? extends ClassLoader> classLoaderClazz =\n                    (Class<? extends ClassLoader>) Class.forName(classLoaderName, true, classLoader);\n            return classLoaderClazz.getDeclaredConstructor(String.class, URL[].class, ClassLoader.class, List.class);\n        } catch (ReflectiveOperationException ex) {\n            throw new IllegalStateException(classLoaderName +  \" initialize fail Caused by:\" + ex.getMessage(), ex);\n        }\n    }\n\n\n    @Override\n    public ClassLoader createClassLoader(String name, URL[] urls, ClassLoader parent, List<String> libClass) {\n        try {\n            return constructor.newInstance(name, urls, parent, libClass);\n        } catch (ReflectiveOperationException ex) {\n            throw new IllegalStateException(constructor + \" invoke fail Caused by:\" + ex.getMessage(), ex);\n        }\n    }\n}\n","sourceCodeStart":33,"sourceCodeEnd":55,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/classloader/DynamicClassLoaderFactory.java#L33-L55","documentation":"createClassLoader calls the cached reflective constructor via newInstance. If instantiation throws (IllegalAccessException, InstantiationException, InvocationTargetException from the target constructor), it is rethrown as IllegalStateException '<ctor> invoke fail Caused by:...'.","triggerScenarios":"The target classloader's constructor itself throws (e.g. invalid URLs, null name), the constructor is not public, or the declaring class failed initialization, when DynamicClassLoaderFactory.createClassLoader runs.","commonSituations":"Classloader constructor validating URLs and throwing on a missing jar path, security manager blocking reflective access, or class initialization errors in the custom classloader.","solutions":["Check the Caused-by chain to find the exception thrown inside the target constructor","Fix the URL[]/name/parent arguments passed into createClassLoader","Make the target constructor public and ensure it does not throw on valid input","Ensure no security manager / JPMS restrictions block reflective access"],"exampleFix":"// before\ncreateClassLoader(\"pinpoint\", new URL[]{new File(\"missing.jar\").toURI().toURL()}, parent, libs);\n// after\nFile jar = new File(\"lib/agent.jar\");\nif (!jar.exists()) throw new IllegalArgumentException(\"agent jar missing\");\ncreateClassLoader(\"pinpoint\", new URL[]{jar.toURI().toURL()}, parent, libs);","handlingStrategy":"try-catch","validationCode":"// pre-validate args passed to createClassLoader\nObjects.requireNonNull(name, \"loader name\");\nObjects.requireNonNull(urls, \"urls\");\nfor (URL u : urls) { try { u.openStream().close(); } catch (IOException ioe) { throw new IllegalArgumentException(\"Unreachable classpath entry: \" + u); } }","typeGuard":null,"tryCatchPattern":"try { ClassLoader cl = factory.createClassLoader(name, urls, parent, libs); } catch (IllegalStateException e) { Throwable cause = e.getCause(); if (cause instanceof InvocationTargetException) { log.error(\"Target constructor threw: {}\", cause.getCause()); } throw e; }","preventionTips":["Inspect the full cause chain — the real failure is inside the target constructor","Validate URL entries exist before passing them","Make custom classloader constructors public and side-effect-free","Avoid SecurityManager setups that block reflective instantiation"],"tags":["java","reflection","classloader"],"backgroundTag":"invalid-constructor-argument","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"}