Hello all,
I'm having a problem that I cannot seem to find a solution for and hoping someone here might be able to help. I have a server program and a client program, both are using the latest version of Springboot. The server provides a restful api for the client to make calls to. The server is working fine, my question lies with the client. I have the below two functions. And the calling code for the functions. I'm using IntelliJ for an IDE and maven for my build tool. When I test the code in IntelliJ with debug or just regular Run, it works perfectly fine. Both calls to the API hit the server and return the expected data. However, after compiling the program to a JAR and running, the first call to getLogLines (calling the api /logs/getloglines) works fine, but then the second call to /oauth2/isLoggedIn just hangs and then errors with java.net.ConnectException ultimately tracing to caused by java.nio.channels.ClosedChannelException. The error traces back to the httpClient.send call.

I'm at a complete loss here. I've tried using multiple methods for generating a request and all of them exhibit this problem. I do not understand how it works when I'm running in IntelliJ, but doesn't when running the jar. I'm using the same version of java for both (I have IntelliJ set to use the installed version of Java 18 in the Project Structure).

Anyone have any ideas here? Btw, I know some of the code here isn't done in the best way possible, this is the result of me spending a lot of time breaking things down a lot to try and find where the problem was lol. I'll clean it up once I actually get this working...

This is the code that is calling it (part of a scheduled task)
public void updateLogLines() {
        try {
            logLinePatterns = logService.getLogLines();
            log.info("Retrieved " + logLinePatterns.size() + " log patterns.");
            logLinesLoaded = true;
            isLoggedIn = logService.isLoggedIn();
        } catch (Exception ex) {
            log.info("Unable to load log lines.");
            ex.printStackTrace();
        }
    }

These are the functions in the my logService that is being referenced
    public List<LogLine> getLogLines() {
        String url = apiBaseUrl + "logs/getloglines";
        System.out.println(url);
        HttpClient httpClient = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder(
                        URI.create(url))
                .header("accept", "application/json")
                .build();
        List<LogLine> logLines = new ArrayList<>();
        try {
            HttpResponse<String> response = httpClient.send(request,HttpResponse.BodyHandlers.ofString());
            logLines = new ObjectMapper().readValue(response.body(), new TypeReference<List<LogLine>>() {});
        } catch (Exception ex) {
            ex.printStackTrace();
        }
 
        return logLines;
    }
 
    public boolean isLoggedIn() throws IOException, InterruptedException {
        HttpClient httpClient = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder(
                                URI.create(uiBaseUrl + "oauth2/isLoggedIn"))
                                    .header("accept", "application/json")
                                    .build();
        System.out.print("...");
        boolean isLoggedIn = false;
        try {
            HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
            System.out.println(response);
            isLoggedIn = Boolean.parseBoolean(response.body());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return isLoggedIn;
    }