{"record":{"id":"2b12bbf0d1dfb3ff","repo":"quarkusio/quarkus","slug":"cannot-invoke-method-classname-name-on-in","errorCode":null,"errorMessage":"Cannot invoke method: ${className}#${name} on ${instance}","messagePattern":"Cannot invoke method: (.+?)#(.+?) on (.+?)","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Reflections.java","lineNumber":188,"sourceCode":"            field.set(instance, value);\n        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {\n            throw new RuntimeException(\"Cannot set field value: \" + clazz.getName() + \"#\" + name, e);\n        }\n    }\n\n    public static Object invokeMethod(Class<?> clazz, String name, Class<?>[] paramTypes, Object instance, Object[] args) {\n        try {\n            Method method = clazz.getDeclaredMethod(name, paramTypes);\n            if (!method.canAccess(instance)) {\n                method.setAccessible(true);\n            }\n            return method.invoke(instance, args);\n        } catch (InvocationTargetException e) {\n            Throwable t = e.getTargetException();\n            if (t instanceof RuntimeException) {\n                throw (RuntimeException) t;\n            }\n            throw new RuntimeException(\"Cannot invoke method: \" + clazz.getName() + \"#\" + name + \" on \" + instance, e);\n        } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | IllegalAccessException e) {\n            throw new RuntimeException(\"Cannot invoke method: \" + clazz.getName() + \"#\" + name + \" on \" + instance, e);\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    static <T> T cast(Object obj) {\n        return (T) obj;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public static <T> Class<T> getRawType(Type type) {\n        if (type instanceof Class<?>) {\n            return (Class<T>) type;\n        }\n        if (isParameterizedType(type)) {\n            final ParameterizedType parameterizedType = asParameterizedType(type);\n            if (parameterizedType.getRawType() instanceof Class<?>) {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Reflections.java#L170-L206","documentation":"When Reflections.invokeMethod() calls a method reflectively and the method itself throws a checked exception (wrapped in InvocationTargetException, and not a RuntimeException), ArC rethrows it as this RuntimeException naming the class, method, and target instance. The original failure is attached as the cause.","triggerScenarios":"Invoking a method via Reflections.invokeMethod() whose target throws a checked/non-Runtime Throwable; the InvocationTargetException path re-wraps it since only RuntimeExceptions are unwrapped and rethrown directly.","commonSituations":"Bean callbacks or interceptor-invoked methods throwing checked exceptions during tests; reflective invocation of a method doing I/O that fails; debugging why a wrapped checked exception surfaced from container code.","solutions":["Inspect the cause (InvocationTargetException#getTargetException) for the real failure","Fix the underlying checked exception thrown by the target method","Catch and handle the checked exception inside the invoked method, or change it to throw a RuntimeException","Validate inputs/instance state before the reflective call so the method succeeds"],"exampleFix":"// before\npublic void doWork() throws IOException { Files.readAllBytes(path); }\n// after\npublic void doWork() { try { Files.readAllBytes(path); } catch (IOException e) { throw new UncheckedIOException(e); } }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return Reflections.invokeMethod(clazz, name, types, instance, args); }\ncatch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause != null) log.error(\"Target threw \" + cause, cause);\n    throw e;\n}","preventionTips":["Inspect the cause chain — the real failure is the wrapped target exception","Convert checked exceptions to unchecked inside invoked methods","Validate instance state before reflective invocation"],"tags":["cdi","reflection","method-invocation","checked-exception"],"backgroundTag":"invocation-target-exception","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}