Skip to content

Error running npm test #28

@decomplected

Description

@decomplected

Attempting to run the Spring Cloud Contract example tests I cloned the repo and ran the npm test as described in the README.md. I got the following error ERROR: JAVA_HOME is set to an invalid directory: /root/.sdkman/candidates/java/current/.

Originally I assumed this was an issue with my local install of SDKMAN, but learning the Spring supported docker images also use SDKMAN - I found the directory being called out in the error above matches the Dockerfile's line 19: https://github.com/spring-cloud/spring-cloud-contract/blob/bbb4db35838f62c8e6df7479e64a33bd875f765d/docker/spring-cloud-contract-stub-runner-docker/Dockerfile#L19

I'm running this on a Mac in iTerm2 and from the terminal within IntelliJ with the same results. Here is my terminal output to try and provide additional context:

$ npm -v                                                                                           
6.14.11

$ node -v                                                                                          
v10.24.0

$ java --version                                                                                   
openjdk 11.0.10 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

$ echo $SDKMAN_DIR                                                                                 
/Users/[my_home]/.sdkman

$ echo $JAVA_HOME
/Users/[my_home]/.sdkman/candidates/java/current

$ npm test                                                                                         

> bookstore@1.0.0 test /Users/[my_home]/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
> ./run_tests.sh



Running tests against Artifactory


~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs/docker ~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
Killing docker_artifactory_1 ... done
Killing docker_mongo_1       ... done
~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
Fetching submodules
Submodule path 'spring-cloud-contract-nodejs-external-contracts': checked out '01c1a8a9f0ba4804a907642f48a26a9e3195c1f2'
Entering 'spring-cloud-contract-nodejs-external-contracts'
From https://github.com/spring-cloud-samples/spring-cloud-contract-nodejs-external-contracts
 * branch            master     -> FETCH_HEAD
Successfully rebased and updated detached HEAD.
Building docker
~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs/docker ~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
Going to remove docker_artifactory_1, docker_mongo_1
Removing docker_artifactory_1 ... done
Removing docker_mongo_1       ... done
mongo uses an image, skipping
Building artifactory
Step 1/4 : FROM docker.bintray.io/jfrog/artifactory-oss:5.5.1
 ---> add606aca80a
Step 2/4 : MAINTAINER Marcin Grzejszczak <mgrzejszczak@pivotal.io>
 ---> Using cache
 ---> f0bb37404ef7
Step 3/4 : COPY artifactory.config.import.yml /var/opt/jfrog/artifactory/etc/artifactory.config.import.yml
 ---> Using cache
 ---> bc69e380670a
Step 4/4 : ENTRYPOINT ["/bin/sh", "-c", "/entrypoint-artifactory.sh"]
 ---> Using cache
 ---> e56f266e24a4

Successfully built e56f266e24a4
Successfully tagged docker_artifactory:latest
Creating docker_mongo_1       ... done
Creating docker_artifactory_1 ... done
~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
Waiting for 30 seconds for artifactory to boot properly
Working around certificate issues
up to date in 4.965s
[!] 215 vulnerabilities found [1263 packages audited]
    Severity: 89 Low | 14 Moderate | 112 High
    Run `npm audit` for more detail

+ express@4.17.1
updated 1 package in 6.156s
[!] 215 vulnerabilities found [1263 packages audited]
    Severity: 89 Low | 14 Moderate | 112 High
    Run `npm audit` for more detail

appending output to nohup.out
Sc Contract Version [3.0.2-SNAPSHOT]
Application URL [http://host.docker.internal:9876]
Artifactory URL [http://host.docker.internal:8081/artifactory/libs-release-local]
Project Version [0.0.1.RELEASE]
Setting project name to [bookstore]
Running the build

ERROR: JAVA_HOME is set to an invalid directory: /root/.sdkman/candidates/java/current/

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

npm ERR! Test failed.  See above for more details.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions