{"record":{"id":"5346ffc9512ffc78","repo":"apache/dubbo","slug":"t-getmessage-5346ff","errorCode":null,"errorMessage":"<t.getMessage()>","messagePattern":"<t\\.getMessage\\(\\)>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java","lineNumber":283,"sourceCode":"            }\n            setProtocols(tmpProtocols);\n        }\n    }\n\n    public Class<?> getInterfaceClass() {\n        if (interfaceClass != null) {\n            return interfaceClass;\n        }\n        if (ref instanceof GenericService) {\n            return GenericService.class;\n        }\n        try {\n            if (StringUtils.isNotEmpty(interfaceName)) {\n                interfaceClass = Class.forName(\n                        interfaceName, true, Thread.currentThread().getContextClassLoader());\n            }\n        } catch (ClassNotFoundException t) {\n            throw new IllegalStateException(t.getMessage(), t);\n        }\n        return interfaceClass;\n    }\n\n    /**\n     * @see #setInterface(Class)\n     * @deprecated\n     */\n    public void setInterfaceClass(Class<?> interfaceClass) {\n        setInterface(interfaceClass);\n    }\n\n    public void setInterface(Class<?> interfaceClass) {\n        this.interfaceClass = interfaceClass;\n        checkInterface();\n        setInterface(interfaceClass == null ? null : interfaceClass.getName());\n        if (getInterfaceClassLoader() == null) {\n            setInterfaceClassLoader(interfaceClass == null ? null : interfaceClass.getClassLoader());","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java#L265-L301","documentation":"Thrown by ServiceConfigBase.getInterfaceClass when the interface class name cannot be loaded via the context ClassLoader (ClassNotFoundException wrapped in IllegalStateException). This is the lazy-resolution path triggered when interfaceClass is null and ref is not a GenericService.","triggerScenarios":"Calling getInterfaceClass() when interfaceClass == null, ref is not a GenericService, interfaceName is non-empty, and Class.forName(interfaceName, true, TCCL) throws ClassNotFoundException.","commonSituations":"Provider module missing the API JAR that declares the interface. Wrong/stale interfaceName. Context ClassLoader swapped to one that cannot see the interface. Shading/relocation that renamed the interface. Provider and consumer using different classloaders (e.g. OSGi, custom plugin loaders).","solutions":["Ensure the interface class is on the classpath visible to the thread context ClassLoader.","Set the interfaceClass explicitly via setInterface(Class) before calling getInterfaceClass().","Correct the interfaceName to the actual fully-qualified class name."],"exampleFix":"// before\nserviceConfig.setInterface(\"com.example.OldName\"); // renamed to NewName\nserviceConfig.getInterfaceClass(); // ClassNotFoundException\n\n// after\nserviceConfig.setInterface(NewNameService.class);","handlingStrategy":"validation","validationCode":"// Pre-load the interface via TCCL to fail with a clear message\ntry {\n    Class.forName(interfaceName, true, Thread.currentThread().getContextClassLoader());\n} catch (ClassNotFoundException ex) {\n    throw new IllegalStateException(\n        \"Interface class not found on classpath: \" + interfaceName\n            + \" — add the API dependency\", ex);\n}\nserviceConfig.getInterfaceClass();","typeGuard":null,"tryCatchPattern":"try {\n    Class<?> c = serviceConfig.getInterfaceClass();\n} catch (IllegalStateException e) {\n    Throwable root = e.getCause() != null ? e.getCause() : e;\n    throw new RuntimeException(\"Missing interface class \" + serviceConfig.getInterface()\n        + \": add the API JAR to the classpath\", root);\n}","preventionTips":["Include the interface API module in the provider's dependencies.","Prefer setInterface(Class) with an already-loaded class over a name string.","Validate classloader visibility of service interfaces in CI."],"tags":["service-config","classpath","classloader"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}