RestTemplate problem połączenia z serwerem

0

Spring boot nie chce ze mną współpracować, wywala mi buga przy próbie połączenia z serwerem:

LoginController Initializable
2156.609 [Thread-3] DEBUG org.springframework.web.client.RestTemplate - HTTP POST http://localhost:8080/verify
2156.613 [Thread-3] DEBUG org.springframework.web.client.RestTemplate - Accept=[]
Exception in thread "Thread-3" org.springframework.web.client.RestClientException: No HttpMessageConverter for org.example.dto.OperatorCredentialsDto
at [email protected]/org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:997)
at [email protected]/org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:773)
at [email protected]/org.springframework.web.client.RestTemplate.execute(RestTemplate.java:710)
at [email protected]/org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:467)
at org.example/org.example.rest.AuthenticatorImpl.processAuthentication(AuthenticatorImpl.java:30)
at org.example/org.example.rest.AuthenticatorImpl.lambda$authenticate$0(AuthenticatorImpl.java:22)
at java.base/java.lang.Thread.run(Thread.java:832)

Kod:

public class AuthenticatorImpl implements Authenticator {

private static final String AUTHENTICATION_URL = "http://localhost:8080/verify";

private final RestTemplate restTemplate;

public AuthenticatorImpl(){
    restTemplate = new RestTemplate();
}


@Override
public void authenticate(OperatorCredentialsDto operatorCredentialsDto, AuthenticationResultHandler authenticationResultHandler) {
    Runnable authenticationTask = () -> {
        processAuthentication(operatorCredentialsDto, authenticationResultHandler);
    };
    Thread authenticationThread = new Thread(authenticationTask);
    authenticationThread.setDaemon(true);
    authenticationThread.start();
}

private void processAuthentication(OperatorCredentialsDto operatorCredentialsDto, AuthenticationResultHandler authenticationResultHandler) {
    ResponseEntity<OperatorAuthenticationResultDto> responseEntity = restTemplate.postForEntity(AUTHENTICATION_URL, operatorCredentialsDto, OperatorAuthenticationResultDto.class);
    authenticationResultHandler.handle(responseEntity.getBody());
}

}

po stronie backendowej wydaje sie, że wszystko działa ok, wywołałem post w Postmanie i działa bez zarzutów.

2

Masz wszystko napisane w stack trace. Nie da się zdezerializować DTO - pewnie brakuje konstruktora albo jakichś adnotacji.

Z innej beczki - po co ten dziwny Thread? O_o na pewno to ma być odpalane asynchronicznie, nikt nie czeka na efekt działania tej metody? Na pewno chcesz tworzyć z palca wątki? W jaki sposób obsłużysz bledy?

1 użytkowników online, w tym zalogowanych: 0, gości: 1