wavesplatform / Waves

⛓️ Reference Waves Blockchain Node (client) implementation on Scala
https://wavesplatform.com/
MIT License
1.17k stars 417 forks source link

Waves 0.9.2 require Java 9 #862

Closed andyceo closed 6 years ago

andyceo commented 6 years ago

Hello!

When I try to use your 0.9.2 release with Java 8 I get:

andyceo@incuble:~/workspace/dockerfiles/waves$ sudo docker container run --rm andyceo/waves:0.9.2
2018-02-21 10:39:48,224 INFO  [main] c.w.Application$ - Starting...
2018-02-21 10:39:49,751 INFO  [main] kamon.Kamon$Instance - Initializing Kamon...
2018-02-21 10:39:51,349 INFO  [ctor.default-dispatcher-3] a.event.slf4j.Slf4jLogger - Slf4jLogger started
2018-02-21 10:39:51,894 INFO  [ctor.default-dispatcher-3] a.event.slf4j.Slf4jLogger - Slf4jLogger started
2018-02-21 10:39:51,949 INFO  [main] c.w.Application$ - Waves v0.9.2 Blockchain Id: W
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000000016f86, pid=1, tid=0x00007ffa456cfae8
#
# JRE version: OpenJDK Runtime Environment (8.0_151-b12) (build 1.8.0_151-b12)
# Java VM: OpenJDK 64-Bit Server VM (25.151-b12 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 3.6.0
# Distribution: Custom build (Tue Nov 21 11:22:36 GMT 2017)
# Problematic frame:
# C  0x0000000000016f86
#
# Core dump written. Default location: //core or core.1
#
# An error report file with more information is saved as:
# //hs_err_pid1.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   http://icedtea.classpath.org/bugzilla
#

But node works fine with Java 9:

andyceo@incuble:~/workspace/dockerfiles/waves$ sudo docker container run --rm andyceo/waves
2018-02-21 10:37:09,933 INFO  [main] c.w.Application$ - Starting...
2018-02-21 10:37:11,711 INFO  [main] kamon.Kamon$Instance - Initializing Kamon...
2018-02-21 10:37:13,110 INFO  [ctor.default-dispatcher-4] a.event.slf4j.Slf4jLogger - Slf4jLogger started
2018-02-21 10:37:13,775 INFO  [ctor.default-dispatcher-3] a.event.slf4j.Slf4jLogger - Slf4jLogger started
2018-02-21 10:37:13,809 INFO  [main] c.w.Application$ - Waves v0.9.2 Blockchain Id: W
2018-02-21 10:37:15,346 INFO  [main] c.w.s.BlockchainUpdaterImpl - State rebuild started, total persisted blocks: 0, [ in-memory: (Δh=0, Δtxs=0) ] + persisted: h=0
2018-02-21 10:37:15,645 INFO  [main] c.w.state2.StateWriterImpl - BlockDiff commit complete. Persisted height = 0
2018-02-21 10:37:15,670 INFO  [main] c.w.s.BlockchainUpdaterImpl - State rebuild finished, total persisted blocks: 0, [ in-memory: (Δh=0, Δtxs=0) ] + persisted: h=0
...etc...

You documented that Waves need Java 8 here:

Install the JRE 1.8

Also you did not mention anything about Java 9 in your Waves 0.9.2 release notes. Waves 0.8.10 worked fine with Java 8.

Please fix something, docs or node or both, I think your application must work with stable Java versions.

vsuharnikov commented 6 years ago

Hi! Thanks for your contribution and waiting :)

Yes, it didn't work with your image on dockerhub. I went to the docker container:

docker container run -it --rm --entrypoint "/bin/sh" andyceo/waves:0.9.2

And found that:

/ # java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (IcedTea 3.6.0) (Alpine 8.151.12-r0)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

Looks like, you used openjdk:jre-alpine. Note, it is recommended to use slim version if the app doesn't use UI-related java libraries.

I tried to reproduce this bug with other JVMs:

  1. Copied your Dockerfile locally

  2. Changed:

    FROM openjdk:9-jre-slim

    to:

    FROM openjdk:8-jre-slim

    Also added RUN ["java", "-version"] to verify JRE and removed update-ca-certificates && \ (I know, it is critical, but a build hangs often on this line, and it is ok for testing).

    So, the content of the Dockerfile became:

    FROM alpine as crawler
    ENV WAVES_VERSION 0.9.2
    RUN apk add --no-cache --update ca-certificates curl && \
        curl -sLo /waves.jar "https://github.com/wavesplatform/Waves/releases/download/v${WAVES_VERSION}/waves-all-${WAVES_VERSION}.jar" && \
        curl -sLo /waves-devnet.conf "https://raw.githubusercontent.com/wavesplatform/Waves/v${WAVES_VERSION}/waves-devnet.conf" && \
        curl -sLo /waves-mainnet.conf "https://raw.githubusercontent.com/wavesplatform/Waves/v${WAVES_VERSION}/waves-mainnet.conf" && \
        curl -sLo /waves-testnet.conf "https://raw.githubusercontent.com/wavesplatform/Waves/v${WAVES_VERSION}/waves-testnet.conf"
    
    FROM openjdk:8-jre-slim
    MAINTAINER Andrey Andreev <andyceo@yandex.ru> (@andyceo)
    COPY --from=crawler /waves.jar /waves.jar
    COPY --from=crawler /waves-devnet.conf /waves-devnet.conf
    COPY --from=crawler /waves-mainnet.conf /waves-mainnet.conf
    COPY --from=crawler /waves-testnet.conf /waves-testnet.conf
    EXPOSE 6869 6868
    VOLUME ["/root/waves"]
    RUN ["java", "-version"]
    ENTRYPOINT ["/usr/bin/java", "-jar", "/waves.jar"]
    CMD ["/waves-mainnet.conf"]
  3. Removed all previous containers and clear Docker files:

    docker rm -f `docker ps -a -q`; docker rmi waves-docker; docker system prune -f
  4. Built an image from the directory with Dockerfile: docker build -t waves-docker:openjdk8 .

  5. Ran a container: docker run --rm waves-docker:openjdk8

Got:

openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-1~deb9u1-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

when build. And had no error when running.

Next, I tried other JRE's in a same way:

With OracleJDKs I have to change:

ENTRYPOINT ["/usr/bin/java", "-jar", "/waves.jar"]

to:

ENTRYPOINT ["java", "-jar", "/waves.jar"]

PS: Also we plan to distribute and maintain own Docker images in future.