{"record":{"id":"365c8f67a794abd5","repo":"apache/shenyu","slug":"accesstoken-is-null","errorCode":null,"errorMessage":"accessToken is null","messagePattern":"accessToken is null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/HttpClientRegisterRepository.java","lineNumber":199,"sourceCode":"\n    /**\n     * doPersistDiscoveryConfig.\n     *\n     * @param discoveryConfigRegisterDTO discoveryConfigRegisterDTO\n     */\n    public void doPersistDiscoveryConfig(final DiscoveryConfigRegisterDTO discoveryConfigRegisterDTO) {\n        doRegister(discoveryConfigRegisterDTO, Constants.DISCOVERY_CONFIG_PATH, Constants.DISCOVERY_CONFIG_TYPE);\n    }\n\n    private <T> void doRegister(final T t, final String path, final String type) {\n        int i = 0;\n        for (String server : serverList) {\n            i++;\n            String concat = server.concat(path);\n            try {\n                String accessToken = this.accessToken.get(server);\n                if (StringUtils.isBlank(accessToken)) {\n                    throw new NullPointerException(\"accessToken is null\");\n                }\n                RegisterUtils.doRegister(GsonUtils.getInstance().toJson(t), concat, type, accessToken);\n                // considering the situation of multiple clusters, we should continue to execute here\n            } catch (Exception e) {\n                LOGGER.error(\"Register admin url :{} is fail, will retry. cause:{}\", server, e.getMessage());\n                if (i == serverList.size()) {\n                    throw new RuntimeException(e);\n                }\n            }\n        }\n    }\n\n    private <T> void doHeartbeat(final T t, final String path) {\n        int i = 0;\n        for (String server : serverList) {\n            i++;\n            String concat = server.concat(path);\n            try {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/HttpClientRegisterRepository.java#L181-L217","documentation":"HttpClientRegisterRepository.doRegister looks up the cached access token for each admin server before sending a register request; if no token has been stored for that server URL (blank/null map entry) it deliberately throws NullPointerException. The token is normally obtained during the login/handshake phase, so a missing token means the client never authenticated with that admin node.","triggerScenarios":"doRegister invoked (via doPersistURI/doPersistApiDoc/doPersistInterface/doPersistMcpTools/closeRepository/doPersistDiscoveryConfig) before the per-server access token was populated, e.g. login failed, wrong username/password/token config, or the server entry in shenyu.register.serverLists was never contacted successfully.","commonSituations":"Misconfigured shenyu.register.serverLists containing an admin node that never completed login; wrong credentials in shenyu.register.http.username/password; clock/token expiry clearing the map before first register; client registration racing startup before authentication completes.","solutions":["Verify shenyu.register.http.username/password (or accessToken) config matches the admin credentials","Check client logs for the earlier login failure against that admin server","Ensure the admin server URL in serverLists is correct and reachable","Restart the client so the auth/login handshake re-runs before registering"],"exampleFix":"// before\nshenyu:\n  register:\n    serverLists: http://admin1:9095,http://admin2:9095\n    # credentials missing -> accessToken never populated\n// after\nshenyu:\n  register:\n    serverLists: http://admin1:9095,http://admin2:9095\n    username: admin\n    password: admin","handlingStrategy":"validation","validationCode":"String token = accessTokenMap.get(server); if (token == null || token.isBlank()) { reAuthenticate(server); }","typeGuard":null,"tryCatchPattern":"try { repository.doRegister(dto); } catch (Exception e) { log.error(\"register failed, token/auth issue: {}\", e.getMessage()); scheduleRetry(); }","preventionTips":["Always configure register username/password matching admin","Check client startup logs for successful login before services register","Keep serverLists limited to reachable admin nodes"],"tags":["http","register-client","authentication","config"],"backgroundTag":"missing-credentials","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}