heroku / heroku-sbt-plugin

An sbt plugin for deploying Heroku Scala applications
MIT License
0 stars 0 forks source link

herokuJdkUrl does not work #19

Closed jmaynier closed 9 years ago

jmaynier commented 9 years ago

We want to use the sbt-heroku project to deploy our app using an oracle jdk (because we have R14 and R15 memory issues and we think that oracle jdk can solve that). We tried to use herokuJdkUrl in our build.sbt file but it seems not to work. After digging into the code of sbt-heroku we found that it calls the wrong signature methods of deploySlug in heroku-maven-plugin Bug is in sbt-heroku/src/main/scala/com/heroku/sbt/HerokuPlugin.scala line 55

deploySlug(includedFiles, configVars, jdkUrlOrVersion, stack, processTypes, "slug.tgz")

When an herokuJdkUrl it should use the 2nd method instead of the first one.

public void deploySlug(List<File> includedFiles, Map<String, String> configVars, String jdkVersion, String stack, Map<String, String> processTypes, String tarFilename) throws Exception {
    deploySlug(includedFiles, configVars, jdkVersion, null, stack, processTypes, tarFilename);
  }

public void deploySlug(List<File> includedFiles, Map<String, String> configVars, URL jdkUrl, String stack, Map<String, String> processTypes, String tarFilename) throws Exception {
    deploySlug(includedFiles, configVars, jdkUrl.toString(), jdkUrl, stack, processTypes, tarFilename);
  }
jkutner commented 9 years ago

Did you try the deployHerokuSlug task? That's the only task intended to work with this option (I should clarify that in the docs). Otherwise, are you on version 0.4.2? I think if you back down to 0.3.7 the herokuJdkUrl will work. Also, on 0.4.2

In version 0.4.2 with the deployHeroku task, the JDK is actually installed on Heroku by a buildpack. It is possible to configure the URL for the buildpack by setting this config var:

$ heroku config:set JDK_URL_1_8="http://url.to.your.tarball..."

However, I think it's unlikely that Oracle JDK will help you. If you open a ticket with Heroku Support we can help you do some profile and maybe identify the cause.

Regardless, I'll look into getting this fixed (or clarifying the docs)

leo-dur commented 9 years ago

Thanks for the prompt reply.

We are using sbt-heroku 0.4.2 and deployHerokuSlug.

We get the error: java.lang.IllegalArgumentException: Invalid JDK version: http://lang-jvm.s3.amazonaws.com/jdk/openjdk1.8.0_20.tar.gz

Because jdkUrlOrVersion is a String and not an URL, the wrong deploySlug method is called.

If I modify sbt-heroku/src/main/scala/com/heroku/sbt/HerokuPlugin.scala as follows I can deploy without error.

          if ((herokuJdkUrl in deployHeroku).value.isEmpty) {
            val jdkVersion : String = (herokuJdkVersion in deployHeroku).value
            sbtApp.deploySlug(includedFiles, configVars, jdkVersion, stack, processTypes, "slug.tgz")
          }
          else {
            val jdkUrl : URL = new URL((herokuJdkUrl in deployHeroku).value)
            sbtApp.deploySlug(includedFiles, configVars, jdkUrl, stack, processTypes, "slug.tgz")
         }
 activator stage deployHerokuSlug
[success] Total time: 2 s, completed May 27, 2015 7:18:54 PM
[info] -----> Packaging application...
[info]        - app: MY_APP
[info]        - including: target/universal/stage/
[info]        - installing: Custom JDK
[info] -----> Creating slug...
[info]        - file: target/heroku/slug.tgz
[info]        - size: 259MB
[info] -----> Uploading slug... (100%)
[info]        - stack: cedar-14
[info]        - process types: [web, console]
[info] -----> Releasing...
[info]        - version: 104
[info] -----> Done

But when I check which jdk is used, with: heroku run console -a MY_APP

I have the following message:

Welcome to Scala version 2.11.6 (OpenJDK 64-Bit Server VM, Java 1.7.0_79).
jkutner commented 9 years ago

Ok i understand now. Thanks for the info. Ill be looking at this very soon and should have a fix quickly.

The 7u79 jdk is the cedar default, so this might mean that the PATH is not set correctly with the new jdk.

jkutner commented 9 years ago

FYI: this is available in 0.4.2 (we both mistakenly referenced 0.4.2 earlier, but I believe we meant 0.4.1).