{"record":{"id":"38c16ea16c88835d","repo":"jwtk/jjwt","slug":"unable-to-invoke-class-method-fqcn-methodname","errorCode":null,"errorMessage":"Unable to invoke class method ${fqcn}#${methodName}.  Ensure the necessary implementation is in the runtime classpath.","messagePattern":"Unable to invoke class method (.+?)#(.+?)\\.  Ensure the necessary implementation is in the runtime classpath\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/io/jsonwebtoken/lang/Classes.java","lineNumber":300,"sourceCode":"     * Invokes the fully qualified class name's method named {@code methodName} with parameters of type {@code argTypes}\n     * using the {@code args} as the method arguments.\n     *\n     * @param fqcn       fully qualified class name to locate\n     * @param methodName name of the method to invoke on the class\n     * @param argTypes   the method argument types supported by the {@code methodName} method\n     * @param args       the runtime arguments to use when invoking the located class method\n     * @param <T>        the expected type of the object returned from the invoked method.\n     * @return the result returned by the invoked method\n     * @since 0.10.0\n     */\n    public static <T> T invokeStatic(String fqcn, String methodName, Class<?>[] argTypes, Object... args) {\n        try {\n            Class<?> clazz = Classes.forName(fqcn);\n            return invokeStatic(clazz, methodName, argTypes, args);\n        } catch (Exception e) {\n            String msg = \"Unable to invoke class method \" + fqcn + \"#\" + methodName + \".  Ensure the necessary \" +\n                    \"implementation is in the runtime classpath.\";\n            throw new IllegalStateException(msg, e);\n        }\n    }\n\n    /**\n     * Invokes the {@code clazz}'s matching static method (named {@code methodName} with exact argument types\n     * of {@code argTypes}) with the given {@code args} arguments, and returns the method return value.\n     *\n     * @param clazz      the class to invoke\n     * @param methodName the name of the static method on {@code clazz} to invoke\n     * @param argTypes   the types of the arguments accepted by the method\n     * @param args       the actual runtime arguments to use when invoking the method\n     * @param <T>        the type of object expected to be returned from the method\n     * @return the result returned by the invoked method.\n     * @since 0.12.0\n     */\n    @SuppressWarnings(\"unchecked\")\n    public static <T> T invokeStatic(Class<?> clazz, String methodName, Class<?>[] argTypes, Object... args) {\n        try {","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/api/src/main/java/io/jsonwebtoken/lang/Classes.java#L282-L318","documentation":"IllegalStateException thrown by the varargs-entry io.jsonwebtoken.lang.Classes.invokeStatic(String fqcn, ...) when it cannot load the class or dispatch to the static method. It delegates to Classes.forName and the Class-based invokeStatic, wrapping any failure with a classpath-oriented hint. This means reflection-based method lookup/invocation failed.","triggerScenarios":"Classes.invokeStatic(fqcn, methodName, argTypes, args) where fqcn is not on the classpath (forName throws), the static method does not exist with those exact argument types, or the invoked method itself throws an exception.","commonSituations":"Missing jjwt-impl jar so implementation classes cannot be loaded; renamed/moved classes across jjwt versions; wrong method name or argument types passed programmatically.","solutions":["Ensure the jar containing the class (often jjwt-impl) is on the runtime classpath","Verify fqcn, methodName, and argTypes exactly match an existing public static method","Check the cause exception: NoClassDefFoundError/ClassNotFoundException means classpath; NoSuchMethodException means signature mismatch","Align library versions if the class moved between jjwt versions"],"exampleFix":"// before\nObject r = Classes.invokeStatic(\"io.jsonwebtoken.impl.crypto.DefaultJwtSigner\", \"sign\", new Class[0], new Object[0]); // class absent\n// after\n// add jjwt-impl to dependencies, then call typed APIs instead of reflection:\nJwtParser p = Jwts.parserBuilder().build();","handlingStrategy":"try-catch","validationCode":"if (!Classes.isAvailable(fqcn)) {\n    throw new IllegalStateException(\"Class \" + fqcn + \" missing — check runtime classpath\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return Classes.invokeStatic(fqcn, methodName, argTypes, args);\n} catch (IllegalStateException e) {\n    if (e.getCause() instanceof ClassNotFoundException) {\n        throw new IllegalStateException(\"Missing jar for \" + fqcn + \" — check classpath\", e);\n    }\n    throw e;\n}","preventionTips":["Prefer typed public APIs over reflective invokeStatic","Keep jjwt module versions aligned to avoid renamed classes","Log e.getCause() to distinguish classpath vs signature problems"],"tags":["reflection","classpath","static-method"],"backgroundTag":"class-not-found","analyzedSha":"fb71496164c71442d08adec4571d9616ed5e1b8d","analyzedAt":"2026-09-09T00:33:09.982Z","contentChangedAt":"2026-09-09T00:33:09.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}