Error: JAVA_HOME is not defined correctly.
brentleemans
PROOP

3 months ago

I'm trying to deploy my basic sprint boot application. I never had this issue occur. I'm using Railpack as my builder, I'm not using the metal build environment.

When it's trying to build I get this error in my console:

./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction

Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/local/bin/java

Deployment ID:
af1aafde-f077-4324-b45d-642c764e152b

Any help is welcome, thank you!

$30 Bounty

6 Replies

Railway
BOT

3 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


bytekeim
PRO

3 months ago

keep using the railpack as ur builder , and create a file name it railpack.json in the root of your repository with this content:

{
  "$schema": "https://schema.railpack.com/",
  "steps": {
    "build": {
      "commands": [
        "unset JAVA_HOME && ./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction"
      ]
    }
  }
}

this unsets the broken JAVA_HOMEthat railpack sets, allowing ./mvnw to fall back to the java that is already on the PATH (provided by Railpack itself). ur original command (including the dependency list log and production profile) is preserved exactly, push this file and deployu

lmk if it works for u


bytekeim

keep using the railpack as ur builder , and create a file name it railpack.json in the root of your repository with this content:{ "$schema": "https://schema.railpack.com/", "steps": { "build": { "commands": [ "unset JAVA_HOME && ./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction" ] } } }this unsets the broken JAVA_HOMEthat railpack sets, allowing ./mvnw to fall back to the java that is already on the PATH (provided by Railpack itself). ur original command (including the dependency list log and production profile) is preserved exactly, push this file and deployulmk if it works for u

brentleemans
PROOP

3 months ago

Now I get a different error:

unset JAVA_HOME && ./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction

115ms

sh: 1: ./mvnw: Permission denied

ERROR: failed to build: failed to solve: process "sh -c unset JAVA_HOME && ./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction" did not complete successfully: exit code: 126

I updated the railpack.json to:

{ "$schema": "https://schema.railpack.com/", "steps": { "build": { "commands": [ "chmod +x mvnw .mvn/wrapper/maven-wrapper.jar", "unset JAVA_HOME && ./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction" ] } } }

Now I get this error:

unset JAVA_HOME && ./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction

226ms

We cannot execute /usr/local/bin/java

copy /usr/local/bin/mise

98ms

ERROR: failed to build: failed to solve: process "sh -c unset JAVA_HOME && ./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction" did not complete successfully: exit code: 1


bytekeim
PRO

3 months ago

yess i see the problem is mise reactivating between the two commands and resetting the bad JAVA_HOME again , that's why it worked for a second then reverted , to fix this put everything in one single command so nothing can interfere

{
  "$schema": "https://schema.railpack.com/",
  "steps": {
    "build": {
      "commands": [
        "chmod +x ./mvnw && unset JAVA_HOME && ./mvnw -DoutputFile=target/mvn-dependency-list.log -B -DskipTests clean dependency:list install -Pproduction"
      ]
    }
  }
}

also run git update-index --chmod=+x mvnw && git commit -m "fix: make mvnw executable" mvnw locally once so you never need the chmod again

lmk the result


bytekeim
PRO

3 months ago

did it work for you ?


brentleemans
PROOP

3 months ago

Sorry I used a Dockerfile for now, I will start using Railpack again once Railway fixes their issues


Loading...