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

  • How to efficiently copy lots of Docker images from one private registry to another?
  • Where should environment-specific values be saved in a Laravel 5 application?
  • Docker does not set the RAM via docker run command
  • Docker volume located in /tmp on OSX empty
  • Kubernetes on Fedora 21 Pod Stays Pending
  • Docker build on apt-get update fails
  • 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 Debian install fails
  • Passive replicas with Docker swarm mode
  • Why php-fpm from official Docker image doesn't work for me?
  • How to hide SSH key to the Docker image without leaving the trace?
  • Capturing output of python script run inside a docker container
  • Connecting the Docker Daemon insde the CDK on RHEL based docker images
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.