laurilehmijoki / s3_website

Manage an S3 website: sync, deliver via CloudFront, benefit from advanced S3 website features.
Other
2.24k stars 187 forks source link

java.lang.RuntimeException: unsupported Java version: 9 #300

Open andersonDadario opened 7 years ago

andersonDadario commented 7 years ago

Tried to use s3_website on Mac and unfortunately it does not run with Java 9

user$ s3_website push --dry-run
[info] Downloading https://github.com/laurilehmijoki/s3_website/releases/download/v3.4.0/s3_website.jar into /var/folders/pv/qhqsh1rj0r11dknn95w1yxbmvfy2z6/T//s3_website-3.4.0.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.jruby.Ruby.newInstance(Ruby.java:266)
    at s3.website.Ruby$.rubyRuntime$lzycompute(Ruby.scala:4)
    at s3.website.Ruby$.rubyRuntime(Ruby.scala:4)
    at s3.website.model.Config$$anonfun$15.apply(Config.scala:229)
    at s3.website.model.Config$$anonfun$15.apply(Config.scala:227)
    at scala.util.Try$.apply(Try.scala:192)
    at s3.website.model.Config$.erbEval(Config.scala:227)
    at s3.website.model.Site$$anonfun$2.apply(Site.scala:28)
    at s3.website.model.Site$$anonfun$2.apply(Site.scala:27)
    at scala.util.Success.flatMap(Try.scala:231)
    at s3.website.model.Site$.parseConfig(Site.scala:27)
    at s3.website.model.Site$.loadSite(Site.scala:100)
    at s3.website.Push$.push(Push.scala:62)
    at s3.website.Push$.main(Push.scala:40)
    at s3.website.Push.main(Push.scala)
Caused by: java.lang.RuntimeException: unsupported Java version: 9
    at org.jruby.RubyInstanceConfig.initGlobalJavaVersion(RubyInstanceConfig.java:1878)
    at org.jruby.RubyInstanceConfig.<clinit>(RubyInstanceConfig.java:1585)
    ... 15 more

Java version

user$ java --version
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
laurilehmijoki commented 7 years ago

Pull request highly appreciated!

laurilehmijoki commented 7 years ago

And thank you for the report :)

andersonDadario commented 7 years ago

Btw @laurilehmijoki , thank you for s3 website. It`s a great project :)

damnginamarketing commented 7 years ago

Also getting the same issue... would love to get this working as it would be my first time using it. Thank you!

——————

Downloading https://github.com/laurilehmijoki/s3_website/releases/download/v3.4.0/s3_website.jar into /Users/clementyeung/.gem/ruby/2.4.2/gems/s3_website-3.4.0/s3_website-3.4.0.jar Exception in thread "main" java.lang.ExceptionInInitializerError at org.jruby.Ruby.newInstance(Ruby.java:266) at s3.website.Ruby$.rubyRuntime$lzycompute(Ruby.scala:4) at s3.website.Ruby$.rubyRuntime(Ruby.scala:4) at s3.website.model.Config$$anonfun$15.apply(Config.scala:229) at s3.website.model.Config$$anonfun$15.apply(Config.scala:227) at scala.util.Try$.apply(Try.scala:192) at s3.website.model.Config$.erbEval(Config.scala:227) at s3.website.model.Site$$anonfun$2.apply(Site.scala:28) at s3.website.model.Site$$anonfun$2.apply(Site.scala:27) at scala.util.Success.flatMap(Try.scala:231) at s3.website.model.Site$.parseConfig(Site.scala:27) at s3.website.model.Site$.loadSite(Site.scala:100) at s3.website.Push$.push(Push.scala:62) at s3.website.Push$.main(Push.scala:40) at s3.website.Push.main(Push.scala) Caused by: java.lang.RuntimeException: unsupported Java version: 9 at org.jruby.RubyInstanceConfig.initGlobalJavaVersion(RubyInstanceConfig.java:1878) at org.jruby.RubyInstanceConfig.<clinit>(RubyInstanceConfig.java:1585) ... 15 more

java --version java 9.0.1 Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

laurilehmijoki commented 7 years ago

A workaround is to use jenv: https://github.com/laurilehmijoki/s3_website/issues/298

alandipert commented 6 years ago

Could this be as simple as upgrading JRuby in build.sbt?

https://github.com/jruby/jruby/issues/4558#issuecomment-295303107

lucascantor commented 6 years ago

My experience figuring out how to use jenv as a workaround, for anyone having trouble:

https://github.com/laurilehmijoki/s3_website/issues/298#issuecomment-361029914

andersonDadario commented 6 years ago

I just used Docker, problem solved.

Here is what I did:

  1. Created a s3_website directory on my app root directory
  2. There I created 3 files:

Dockerfile

FROM ruby:2.3.3

RUN apt-get update -qq && \
    apt-get install --assume-yes -y \
       build-essential \
       libpq-dev \
       openjdk-7-jre \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Use en_US.UTF-8 as our locale
ENV LC_CTYPE en_US.UTF-8
ENV LANG en_US.UTF-8

# Run bundle
RUN gem install s3_website && s3_website install

RUN mkdir /app
VOLUME /app
WORKDIR /app

CMD bash

build.sh

#!/bin/bash
docker build -t utils/s3_website .

deploy.sh

#!/bin/bash

docker run --rm \
    --name s3_website \
    -it \
    -v "$(cd .. && pwd):/app" \
    utils/s3_website \
    s3_website push

And I still keep the s3_website.yml file in my app root folder. The app container will access it through a shared volume.

The process is simple:

  1. Install Docker
  2. $ bash build.sh # just need to do it once to create the image
  3. $ bash deploy.sh # loads info from ../s3_website.yml

Note: I am sure that this process can be optimized, e.g., let --dry-run be parameter for deploy.sh, but so far it works well for me.

xaviershay commented 6 years ago

I tried and failed to make a PR to fix. I know basically nothing about Scala or Java, so no real surprise. Notes:

natseg commented 6 years ago

https://github.com/laurilehmijoki/s3_website/issues/300#issuecomment-345417806 I would also recommend using asdf to manage different versions of java on your mac. It's a meta manager so it can also manage ruby, nodejs, elixir, erlang, ...

That's how I "fixed" this issue on my machine.

AndrewKvalheim commented 6 years ago

For searchability:

Caused by: java.lang.RuntimeException: unsupported Java version: 10
rtrvrtg commented 6 years ago

Got a colleague with the same problem except their runtime exception message is unsupported Java version: 11

Your build dependencies currently indicate that jRuby 1.7.11 is required. jRuby's Github indicates that the latest versions support up to v10: https://github.com/jruby/jruby/blob/ce15c9d63e7312c47c7d86c2852e93a406459c7b/core/src/main/java/org/jruby/RubyInstanceConfig.java

losomo commented 5 years ago

For my future self: Problem:

Caused by: java.lang.RuntimeException: unsupported Java version: 11
    at org.jruby.RubyInstanceConfig.initGlobalJavaVersion(RubyInstanceConfig.java:1878)

Solution:

PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin/:$PATH s3_website push
xaviershay commented 5 years ago

Can confirm that @losomo's workaround worked for me on Ubuntu 18.04 with openjdk-8-jre-headless package installed.

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic
> dpkg -S /usr/lib/jvm/java-1.8.0-openjdk-amd64     
openjdk-8-jre-headless:amd64: /usr/lib/jvm/java-1.8.0-openjdk-amd64
cpury commented 5 years ago

So which Java versions are supported? Can we at least mention that in the Readme? I'd hate to download and install one after the other until I hit one that's supported...

nadnoslen commented 5 years ago

I ended up brewing down to adoptopenjdk8 (Java 8) in order to get this plugin to work.

Annoying because I had to completely uninstall adoptopenjdk11.

I'm stunned that there is a Java dependency locked at 8? I wonder if @alandipert upgrade of JRuby comment would fix this.

yanokwa commented 5 years ago

I've sent in https://github.com/laurilehmijoki/s3_website/pull/329 that should allow our beloved s3_website on recent versions of Java. I would love a review!