Skip to content

Commit 19a14d6

Browse files
authored
bugfix: consoleApiService that could not be found (#7959)
1 parent 95de5bd commit 19a14d6

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

changes/en-us/2.6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Add changes here for all PR submitted to the 2.x branch.
7474
- [[#7891](https://github.com/apache/incubator-seata/pull/7891)] raft split-brain causes incorrect cluster information
7575
- [[#7908](https://github.com/apache/incubator-seata/pull/7908)] handle timestamp with time zone in postgresql primary key
7676
- [[#7938](https://github.com/apache/incubator-seata/pull/7938)] ensure the Jakarta-related package paths are correct.
77+
- [[#7959](https://github.com/apache/incubator-seata/pull/7959)] fix consoleApiService bean that could not be found
7778

7879

7980
### optimize:

changes/zh-cn/2.6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
- [[#7891](https://github.com/apache/incubator-seata/pull/7891)] 修复raft重选举与心跳并发时可能导致namingserver侧的元数据存在多个leader
7575
- [[#7908](https://github.com/apache/incubator-seata/pull/7908)] 在 PostgreSQL 主键中处理带时区的时间戳
7676
- [[#7938](https://github.com/apache/incubator-seata/pull/7938)] 保证Jakarta相关包路径正确
77+
- [[#7959](https://github.com/apache/incubator-seata/pull/7959)] 修复consoleApiService bean未加载的问题
7778

7879

7980
### optimize:

console/src/main/java/org/apache/seata/mcp/service/impl/ConsoleRemoteServiceImpl.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.apache.seata.mcp.service.impl;
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
20-
import org.apache.seata.common.NamingServerLocalMarker;
2120
import org.apache.seata.common.exception.AuthenticationFailedException;
2221
import org.apache.seata.common.util.StringUtils;
2322
import org.apache.seata.console.config.WebSecurityConfig;
@@ -44,10 +43,12 @@
4443
import static org.apache.seata.mcp.core.utils.UrlUtils.buildUrl;
4544
import static org.apache.seata.mcp.core.utils.UrlUtils.objectToQueryParamMap;
4645

47-
@ConditionalOnMissingBean(NamingServerLocalMarker.class)
46+
@ConditionalOnMissingBean(name = "consoleLocalServiceImpl")
4847
@Service
4948
public class ConsoleRemoteServiceImpl implements ConsoleApiService {
5049

50+
private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleRemoteServiceImpl.class);
51+
5152
private final JwtTokenUtils jwtTokenUtils;
5253

5354
private final RestTemplate restTemplate;
@@ -65,10 +66,9 @@ public ConsoleRemoteServiceImpl(
6566
this.restTemplate = restTemplate;
6667
this.objectMapper = objectMapper;
6768
this.namingServerProperties = namingServerProperties;
69+
LOGGER.info("ConsoleRemoteServiceImpl initialized.");
6870
}
6971

70-
private final Logger logger = LoggerFactory.getLogger(ConsoleRemoteServiceImpl.class);
71-
7272
public String getToken() {
7373
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
7474
if (auth == null || !auth.isAuthenticated()) {
@@ -111,13 +111,13 @@ public String getCallNameSpace(String path) {
111111
String errorMsg = String.format(
112112
"MCP GET request failed with status: %s, response: %s",
113113
response.getStatusCode(), response.getBody());
114-
logger.warn(errorMsg);
114+
LOGGER.warn(errorMsg);
115115
throw new ServiceCallException(errorMsg, response.getStatusCode());
116116
}
117117
return responseBody;
118118
} catch (RestClientException e) {
119119
String errorMsg = "MCP GET Call NameSpace Failed.";
120-
logger.error(errorMsg, e);
120+
LOGGER.error(errorMsg, e);
121121
throw new ServiceCallException(errorMsg);
122122
}
123123
}
@@ -151,13 +151,13 @@ public String getCallTC(
151151
String errorMsg = String.format(
152152
"MCP GET request failed with status: %s, response: %s",
153153
response.getStatusCode(), response.getBody());
154-
logger.warn(errorMsg);
154+
LOGGER.warn(errorMsg);
155155
throw new ServiceCallException(errorMsg, response.getStatusCode());
156156
}
157157
return responseBody;
158158
} catch (RestClientException e) {
159159
String errorMsg = "MCP GET Call TC Failed.";
160-
logger.error(errorMsg, e);
160+
LOGGER.error(errorMsg, e);
161161
throw new ServiceCallException(errorMsg);
162162
}
163163
}
@@ -191,13 +191,13 @@ public String deleteCallTC(
191191
String errorMsg = String.format(
192192
"MCP DELETE request returned non-success status: %s, response: %s",
193193
response.getStatusCode(), response.getBody());
194-
logger.warn(errorMsg);
194+
LOGGER.warn(errorMsg);
195195
throw new ServiceCallException(errorMsg, response.getStatusCode());
196196
}
197197
return responseBody;
198198
} catch (RestClientException e) {
199199
String errorMsg = "MCP DELETE Call TC Failed.";
200-
logger.error(errorMsg, e);
200+
LOGGER.error(errorMsg, e);
201201
throw new ServiceCallException(errorMsg);
202202
}
203203
}
@@ -231,13 +231,13 @@ public String putCallTC(
231231
String errorMsg = String.format(
232232
"MCP PUT request returned non-success status: %s, response: %s",
233233
response.getStatusCode(), response.getBody());
234-
logger.warn(errorMsg);
234+
LOGGER.warn(errorMsg);
235235
throw new ServiceCallException(errorMsg, response.getStatusCode());
236236
}
237237
return responseBody;
238238
} catch (RestClientException e) {
239239
String errorMsg = "MCP PUT Call TC Failed.";
240-
logger.error(errorMsg, e);
240+
LOGGER.error(errorMsg, e);
241241
throw new ServiceCallException(errorMsg);
242242
}
243243
}

namingserver/src/main/java/org/apache/seata/namingserver/service/ConsoleLocalServiceImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.seata.mcp.core.props.NameSpaceDetail;
2727
import org.apache.seata.mcp.exception.ServiceCallException;
2828
import org.apache.seata.mcp.service.ConsoleApiService;
29-
import org.apache.seata.mcp.service.impl.ConsoleRemoteServiceImpl;
3029
import org.apache.seata.namingserver.manager.NamingManager;
3130
import org.slf4j.Logger;
3231
import org.slf4j.LoggerFactory;
@@ -48,12 +47,12 @@
4847
import static org.apache.seata.mcp.core.utils.UrlUtils.buildUrl;
4948
import static org.apache.seata.mcp.core.utils.UrlUtils.objectToQueryParamMap;
5049

51-
@ConditionalOnBean(ConsoleRemoteServiceImpl.class)
50+
@ConditionalOnBean(NamingServerLocalMarkerImpl.class)
5251
@Primary
5352
@Service
5453
public class ConsoleLocalServiceImpl implements ConsoleApiService {
5554

56-
private final Logger logger = LoggerFactory.getLogger(this.getClass());
55+
private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleLocalServiceImpl.class);
5756

5857
private final NamingManager namingManager;
5958

@@ -65,6 +64,7 @@ public ConsoleLocalServiceImpl(NamingManager namingManager, RestTemplate restTem
6564
this.namingManager = namingManager;
6665
this.restTemplate = restTemplate;
6766
this.objectMapper = objectMapper;
67+
LOGGER.info("ConsoleLocalServiceImpl initialized.");
6868
}
6969

7070
public String getResult(
@@ -109,13 +109,13 @@ public String getResult(
109109
String errorMsg = String.format(
110110
"MCP request failed with status: %s, response: %s",
111111
response.getStatusCode(), response.getBody());
112-
logger.warn(errorMsg);
112+
LOGGER.warn(errorMsg);
113113
throw new ServiceCallException(errorMsg, response.getStatusCode());
114114
}
115115
return responseBody;
116116
} catch (RestClientException e) {
117117
String errorMsg = "MCP Call TC Failed.";
118-
logger.error(errorMsg, e);
118+
LOGGER.error(errorMsg, e);
119119
throw new ServiceCallException(errorMsg);
120120
}
121121
}
@@ -161,7 +161,7 @@ public String getCallNameSpace(String path) {
161161
try {
162162
namespace = objectMapper.writeValueAsString(namingManager.namespace());
163163
} catch (JsonProcessingException e) {
164-
logger.error("Get NameSpace failed: {}", e.getMessage());
164+
LOGGER.error("Get NameSpace failed: {}", e.getMessage());
165165
return "Failed to get namespace";
166166
}
167167
return namespace;

0 commit comments

Comments
 (0)