Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong JRE version on the docker image #1375

Open
pepjo opened this issue Jan 26, 2023 · 2 comments
Open

Wrong JRE version on the docker image #1375

pepjo opened this issue Jan 26, 2023 · 2 comments

Comments

@pepjo
Copy link

pepjo commented Jan 26, 2023

Describe the bug
When running Franklin from the published docker image I get the following error:

Exception in thread "raster-io-1" java.lang.UnsupportedClassVersionError: com/zaxxer/hikari/HikariConfig has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at com.azavea.franklin.commands.DatabaseConfig$FromComponents.toHikariConfig(DatabaseConfig.scala:54)
        at com.azavea.franklin.api.Server$.$anonfun$createServer$3(Server.scala:95)
        at cats.effect.Resource.$anonfun$fold$1(Resource.scala:124)
        at cats.effect.internals.IOBracket$BracketStart.liftedTree1$1(IOBracket.scala:95)
        at cats.effect.internals.IOBracket$BracketStart.run(IOBracket.scala:95)
        at cats.effect.internals.Trampoline.cats$effect$internals$Trampoline$$immediateLoop(Trampoline.scala:67)
        at cats.effect.internals.Trampoline.startLoop(Trampoline.scala:35)
        at cats.effect.internals.TrampolineEC$JVMTrampoline.super$startLoop(TrampolineEC.scala:90)
        at cats.effect.internals.TrampolineEC$JVMTrampoline.$anonfun$startLoop$1(TrampolineEC.scala:90)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
        at cats.effect.internals.TrampolineEC$JVMTrampoline.startLoop(TrampolineEC.scala:90)
        at cats.effect.internals.Trampoline.execute(Trampoline.scala:43)
        at cats.effect.internals.TrampolineEC.execute(TrampolineEC.scala:42)
        at cats.effect.internals.IOBracket$BracketStart.apply(IOBracket.scala:80)
        at cats.effect.internals.IOBracket$BracketStart.apply(IOBracket.scala:58)
        at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:192)
        at cats.effect.internals.IORunLoop$.restart(IORunLoop.scala:41)
        at cats.effect.internals.IOBracket$.$anonfun$apply$1(IOBracket.scala:48)
        at cats.effect.internals.IOBracket$.$anonfun$apply$1$adapted(IOBracket.scala:34)
        at cats.effect.internals.IOAsync$.$anonfun$apply$1(IOAsync.scala:37)
        at cats.effect.internals.IOAsync$.$anonfun$apply$1$adapted(IOAsync.scala:37)
        at cats.effect.internals.IORunLoop$RestartCallback.start(IORunLoop.scala:464)
        at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:165)
        at cats.effect.internals.IORunLoop$RestartCallback.signal(IORunLoop.scala:480)
        at cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:501)
        at cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:439)
        at cats.effect.internals.IOShift$Tick.run(IOShift.scala:36)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)

which seems to indicate that it's trying to run on Java 8 but needs Java 11. This is confirmed by looking at the Dockerfile here: https://github.com/azavea/franklin/blob/master/application/Dockerfile

Expected behavior
The docker image should come with the right version of docker

Additional context
I've tried the two latest images: quay.io/azavea/franklin:e844dc8 and quay.io/azavea/franklin:adf474c

@pepjo
Copy link
Author

pepjo commented Jan 26, 2023

I've tried building my own docker image using JRE 11 and it seems to work, I used:

FROM quay.io/azavea/franklin:adf474c AS franklin

FROM openjdk:11-jre-slim

RUN \
      addgroup --system franklin \
      && adduser --system --disabled-login --disabled-password \
      --home /var/lib/franklin \
      --shell /sbin/nologin \
      --ingroup franklin \
      -u 1000 \
      franklin

COPY --from=franklin /var/lib/franklin/ /var/lib/franklin/

USER franklin
WORKDIR /var/lib/franklin

ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-jar", "franklin-api-assembly.jar"]

I had to remove UseCGroupMemoryLimitForHeap since it is no longer supported.

I am happy to make a PR with the changes.

@FireByTrial
Copy link

I had the same issue but had to make some minor changes to the application/Dockerfile.dev and docker-compose.yml

I had to add the data-files directory (could use copy too)

FROM quay.io/azavea/franklin:adf474c AS franklin

FROM openjdk:11-jre-slim

RUN \
      addgroup --system franklin \
      && adduser --system --disabled-login --disabled-password \
      --home /var/lib/franklin \
      --shell /sbin/nologin \
      --ingroup franklin \
      -u 1000 \
      franklin

COPY --from=franklin /var/lib/franklin/ /var/lib/franklin/

USER franklin
WORKDIR /var/lib/franklin

ADD ./data-files /var/lib/data-files

ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-jar", "franklin-api-assembly.jar"]

and the command in the docker-compose.yml needed to be updated to:

version: '2.3'
services:
  franklin:
    container_name: franklin-app
    build:
      context: .
      dockerfile: application/Dockerfile.dev
    environment:
      - PGHOST=pgstac
      - PGDATABASE=postgis
      - PGUSER=franklin
      - PGPASSWORD=franklin
      - API_STAC_HIERARCHY=data-files/hierarchy_example.json
    ports:
      - "9090:9090"
    volumes:
      - ./:/opt/src/
    command: serve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants