Why getting ExceptionInInitializerError using orElseThrow

I am writing microservices which will be dockerized and deployed on AWS. Part of the Integration test is to run Docker Compose on this Yaml file to start Docker container and run Docker images locally.

When I run the integration test with Maven, I am getting ExceptionInInitializerError. After some debugging, I realized that it existed before running docker-compose on the yaml file. The stack trace further indicate this is related to the path

  • logstash on docker: set multiple pipeline
  • docker info command doesn't show anything in ec2 Instance
  • Docker registry image won't start - “exec format error”
  • Run nginx in docker with custom vhost
  • Docker compose file memory, cpu limits
  • Docker compose wordpress plugins
  • java.lang.ExceptionInInitializerError: null
            at com.palantir.docker.compose.execution.DockerComposeExecutable.lambda$dockerComposePath$8(DockerComposeExecutable.java:52)
            at java.util.Optional.orElseThrow(Optional.java:290)
            at com.palantir.docker.compose.execution.DockerComposeExecutable.dockerComposePath(DockerComposeExecutable.java:52)

    The exception is thrown at line 52 where orElseThrow is at inside the function below:

    protected String dockerComposePath() {
        String pathToUse = DOCKER_COMPOSE_LOCATIONS.preferredLocation()
                .orElseThrow(() -> new IllegalStateException(
                        "Could not find docker-compose, looked in: " + DOCKER_COMPOSE_LOCATIONS));
        log.debug("Using docker-compose found at " + pathToUse);
        return pathToUse;

    The constant DOCKER_COMPOSE_LOCSATIONS is defined in earlier section of the same class

     private static final DockerCommandLocations DOCKER_COMPOSE_LOCATIONS = new DockerCommandLocations(

    The method preferredLocation basically verifies the paths of docker-compose

    public Optional<String> preferredLocation() {
            return possiblePaths.stream()

    Since I am on a PC on which docker-compose is installed at /c/Program Files/Docker Toolbox/docker-compose, these Linux style paths /usr/.... are not valid. However, I did not have DOCKER_COMPOSE_LOCATION pointing to the right path in my environment. So this might be what is causing ExceptionInInitializerError. What I don’t understand is if the path is not defined, it should have thrown IllegalStateException according to the orElseThrow and printed out the message Could not find docker-compose, looked in. Why does it throw error ExceptionInInitializerError?

    PS even if I set the DOCKER_COMPOSE_LOCATION with the right path in my environment, it is still throwing the same error.

  • Docker kill not working when executed in shell script
  • Passing argument to python application running on docker
  • How to run shell script on host from docker container?
  • Redirecting all requests of one docker container to another ??
  • I start docker with a shell script but when the shell script exits, the container crashes
  • How does docker manage to get a return code of 200 instead of 401
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.