web-frameworks icon indicating copy to clipboard operation
web-frameworks copied to clipboard

[Java/helidon]: first attemp at introducing Helidon

Open whiplash opened this issue 3 years ago • 2 comments

whiplash avatar Sep 19 '22 12:09 whiplash

not sure what's going on here

whiplash avatar Sep 20 '22 11:09 whiplash

it run inside the first layer, seems to be something not copied between containes

waghanza avatar Sep 20 '22 12:09 waghanza

anything I can try to fix this?

whiplash avatar Sep 28 '22 17:09 whiplash

maybe creating a all-in-one jar, honestly not sure to remember the name, fatjar, uberjar ... the idea is to have one jar file without extra dependencies.

the jar is not working since some required library are not copied from build container

waghanza avatar Sep 28 '22 18:09 waghanza

the idea is to have one jar file

this is what mvn package does

whiplash avatar Sep 28 '22 18:09 whiplash

then this issue comes from pom.xml, I mean a class could not be found Caused by: java.lang.NoClassDefFoundError: io/helidon/media/common/MediaSupport

try :

  • bundle exec rake config
  • cd java/helidon
  • docker build . -f .Dockerfile -t test
  • docker run -ti test ash
  • /usr/bin/java -XX:-RelaxAccessControlCheck -XX:+UseNUMA -XX:+UseParallelGC -jar /opt/web/target/helidon.webserver.jar

waghanza avatar Sep 28 '22 21:09 waghanza

still an error

Error: Unable to initialize main class web.helidon.Main
Caused by: java.lang.NoClassDefFoundError: io/helidon/media/common/MediaSupport

waghanza avatar Sep 29 '22 07:09 waghanza

let's see if @tomas-langer or @barchetta can help

whiplash avatar Sep 29 '22 07:09 whiplash

I pulled this PR and I can build and run the helidon application in a shell. My hunch is you are not copying target/libs to your container image.

Our default packaging consists of:

  1. target/application.jar: this contains the application code and a Class-Path entry for runtime dependencies
  2. target/libs: contains all runtime dependencies for the application as referenced by the jar's Class-Path

barchetta avatar Sep 29 '22 15:09 barchetta

Thanks @barchetta! I'm wondering if there's a way to create a sort of uber-jar that will also contain all those libs.

whiplash avatar Sep 29 '22 21:09 whiplash

@whiplash we consider the uber-jar an anti-pattern as they are not Docker image friendly and they introduce complexities concerning merging of resources (like META-INF/services/*).

Another thing to note is that we support packaging the application as a jlink runtime image. I have verified that this works with this PR:

mvn clean install -Pjlink-image
target/helidon.webserver-jri/bin/start

In this case target/helidon.webserver-jri contains a custom Java Runtime Image, plus the application code, plus the runtime dependencies.

barchetta avatar Sep 29 '22 22:09 barchetta

Thanks so much @barchetta.

@waghanza we can try with this jlink runtime and see how it goes

whiplash avatar Sep 30 '22 07:09 whiplash

@waghanza maybe we made it :)

whiplash avatar Sep 30 '22 08:09 whiplash