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

[Scala] Use sbt official docker images #6159

Merged
merged 11 commits into from
Mar 24, 2023
Merged

Conversation

waghanza
Copy link
Collaborator

This PR switch the current docker images to https://github.com/sbt/docker-sbt.

The idea is to :

  • allow using 2.x and 3.x
  • use more official images

However, it is https://projects.eclipse.org/projects/adoptium.temurin and I have to admit, I'm loss about all java platforms.

@waghanza waghanza requested a review from whiplash February 21, 2023 20:45
@waghanza waghanza force-pushed the scala/multiple_version branch from 7e42b7e to 94d1384 Compare February 21, 2023 21:00
@waghanza waghanza force-pushed the scala/multiple_version branch from 94d1384 to 71e10cc Compare February 21, 2023 21:08
@waghanza waghanza requested a review from cacoco February 22, 2023 05:55
@waghanza
Copy link
Collaborator Author

With finatra, I have

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.twitter.jvm.Hotspot (file:/usr/src/app/server-0.1.0-SNAPSHOT/lib/com.twitter.util-jvm_2.13-22.12.0.jar) to field sun.management.ManagementFactoryHelper.jvm
WARNING: Please consider reporting this to the maintainers of com.twitter.jvm.Hotspot
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

The dockerfile is

FROM sbtscala/scala-sbt:eclipse-temurin-focal-17.0.5_8_1.8.2_2.13.10 AS build


WORKDIR /usr/src/app

COPY . ./

RUN sbt universal:packageZipTarball

FROM eclipse-temurin:17-jre-jammy

WORKDIR /usr/src/app

COPY --from=build /usr/src/app/target target

RUN tar -xvzf target/universal/server-0.1.0-SNAPSHOT.tgz

CMD server-0.1.0-SNAPSHOT/bin/server

@whiplash
Copy link
Contributor

it's just warnings

@waghanza
Copy link
Collaborator Author

but Ci is still failing, not sure why

@waghanza
Copy link
Collaborator Author

waghanza commented Mar 23, 2023

I have also (for finatra) => on jre 17

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2051)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3953)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3976)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4960)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4966)
	at com.google.inject.internal.FailableCache.get(FailableCache.java:54)
	at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49)
	at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:155)
	at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:606)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:943)
	at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:863)
	at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:300)
	at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:231)
	at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:949)
	at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:48)
	at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:60)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:135)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:108)
	at com.google.inject.Guice.createInjector(Guice.java:87)
	at com.google.inject.Guice.createInjector(Guice.java:78)
	at com.twitter.inject.app.internal.Modules.install(Modules.scala:108)
	at com.twitter.inject.app.App.loadModules(App.scala:254)
	at com.twitter.inject.app.App.loadModules$(App.scala:251)
	at WebServer.loadModules(WebServer.scala:11)
	at com.twitter.inject.app.App.$anonfun$main$1(App.scala:143)
	at com.twitter.app.lifecycle.Notifier.execAndSignal(Notifier.scala:43)
	at com.twitter.app.lifecycle.Notifier.apply(Notifier.scala:20)
	at com.twitter.app.Lifecycle.observe(Lifecycle.scala:21)
	at com.twitter.app.Lifecycle.observe$(Lifecycle.scala:20)
	at WebServer.observe(WebServer.scala:11)
	at com.twitter.inject.app.App.main(App.scala:142)
	at com.twitter.inject.app.App.main$(App.scala:141)
	at com.twitter.inject.server.TwitterServer.main(TwitterServer.scala:170)
	at com.twitter.inject.server.TwitterServer.main$(TwitterServer.scala:169)
	at WebServer.main(WebServer.scala:11)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at com.twitter.app.App.$anonfun$nonExitingMain$10(App.scala:442)
	at scala.Option.foreach(Option.scala:437)
	at com.twitter.app.App.$anonfun$nonExitingMain$9(App.scala:441)
	at com.twitter.app.lifecycle.Notifier.execAndSignal(Notifier.scala:43)
	at com.twitter.app.lifecycle.Notifier.apply(Notifier.scala:20)
	at com.twitter.app.Lifecycle.observe(Lifecycle.scala:21)
	at com.twitter.app.Lifecycle.observe$(Lifecycle.scala:20)
	at WebServer.observe(WebServer.scala:11)
	at com.twitter.app.App.nonExitingMain(App.scala:432)
	at com.twitter.app.App.nonExitingMain$(App.scala:416)
	at WebServer.nonExitingMain(WebServer.scala:11)
	at com.twitter.app.App.main(App.scala:405)
	at com.twitter.app.App.main$(App.scala:403)
	at WebServer.main(WebServer.scala:11)
	at HelloWorldServerMain.main(WebServer.scala)
Caused by: java.lang.IllegalStateException: Unable to load cache item
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:79)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.get(LoadingCache.java:34)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:294)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65)
	at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:258)
	at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:207)
	at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:49)
	at com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:156)
	at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:94)
	at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:30)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:38)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:34)
	at com.google.inject.internal.FailableCache$1.load(FailableCache.java:43)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3529)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2278)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2155)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2045)
	... 53 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapper
	at com.google.inject.internal.cglib.core.$DuplicatesPredicate.evaluate(DuplicatesPredicate.java:104)
	at com.google.inject.internal.cglib.core.$CollectionUtils.filter(CollectionUtils.java:52)
	at com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init>(FastClassEmitter.java:69)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:77)
	at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.generate(AbstractClassGenerator.java:332)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache$2.call(LoadingCache.java:54)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry(LoadingCache.java:61)
	... 70 more
Exception thrown in main on startup

@whiplash @cacoco

@cacoco
Copy link

cacoco commented Mar 23, 2023

@waghanza I'm not sure what the issue is but it looks very similar to nroduit/Weasis#201 potentially. For some reason, a necessary class is missing from the classpath. My guess would be the change in JDK in the scala/Dockerfile:

- openjdk:11.0.16-jre
+ eclipse-temurin:11-jre-jammy

no longer includes some internal classes that the cglib library expects?

@waghanza
Copy link
Collaborator Author

You are right @cacoco, it is working with jre 11

@cacoco
Copy link

cacoco commented Mar 23, 2023

@waghanza looking into it, it seems a known problem that cglib has issues with JDK16 and JDK17 (see: cglib/cglib#191). This likely means Guice 4.X has issues with JDK16/17 (see this issue: google/guice#1536) and thus Finatra would have to be updated to a compatible version of Guice to work with JDK16/17. Finatra is still technically only compatible with JDK8/11. The future of the framework is murky at best, so I do not know how likely this is to happen any time soon.

@waghanza
Copy link
Collaborator Author

Thanks @cacoco for your clear explanations.

I'll leave jre11 for scala frameworks, and will check in the future which version is accurate.

I'm sure some frameworks like zio or else could run with the latest LTS (and also since jre/jdk 20 will be out soon and LTS)

@waghanza waghanza enabled auto-merge (squash) March 24, 2023 14:02
@waghanza waghanza disabled auto-merge March 24, 2023 14:03
@waghanza waghanza merged commit edef6d5 into master Mar 24, 2023
@waghanza waghanza deleted the scala/multiple_version branch March 24, 2023 14:03
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

Successfully merging this pull request may close these issues.

3 participants