Я создал простую службу микропрофилей eclipse, работающую в openliberty. Мой клиентский файл выглядит так.
@RegisterRestClient(configKey = "ra-api")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface MyClient extends AutoCloseable {
@POST
@Path("/user")
CompletionStage<JsonObject>createUser(String userInfo);
}
Затем я вызываю это из моего класса обслуживания следующим образом.
@Stateless(name="MyClientFunctions")
public class MyClientFunctionsImpl implements MyClientFunctions {
@Inject
@RestClient
protected MyClient raClient;
@Override
public Map<String, Object> createRemoteUser(final Map<String, Object> parameters, final Connection connection) {
String body = Json.createObjectBuilder()
.add("name", guid)
.add("email", userEmail)
.add("role", "User")
.add("invite", false)
.add("send_email", false)
.add("license", "expert")
.add("username", guid).build().toString();
try {
CompletionStage<JsonObject> userInfoFuture = raClient.createUser(body);
jsonResult = ((CompletableFuture<JsonObject>) userInfoFuture).join();
retMap.put("UserInfo", jsonResult);
}
catch (Exception e) {
Logger.getLogger(MyClientFunctionsImpl.class.getName()).log(Level.SEVERE, null, e.getMessage());
}
И после строки CompletionStage<JsonObject> userInfoFuture = raClient.createUser(body);
он напрямую переходит в catch
и печатает
[ERROR] null
и когда я проверяю raClient
, также null. Что является причиной этого? Пожалуйста, помогите мне. Спасибо `