Skip to content

Native image compatibility #61

Closed
zscauer opened this issue May 26, 2023 · 5 comments · Fixed by #62
Closed

Native image compatibility #61

zscauer opened this issue May 26, 2023 · 5 comments · Fixed by #62

Comments

@zscauer
Copy link
Contributor

zscauer commented May 26, 2023

Был ли у кого нибудь успешный опыт сборки native image приложения с данным sdk?
Пробовал собрать spring и quarkus (все последней версии), но не получается собрать из-за библиотеки
io.grpc:grpc-netty-shaded.

Во время сборки возникают ошибки относительно различных классов вроде этой:

Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException:
Discovered unresolved type during parsing: org.apache.log4j.Logger.
This error is reported at image build time because class io.grpc.netty.shaded.io.netty.util.internal.logging.Log4JLoggerFactory is registered for linking at image build time by command line

Попытки проинициализировать проблемные классы в runtime вместо buildtime безуспешны.

zscauer added a commit to zscauer/tinkoff-invest-api-java-sdk-old that referenced this issue May 26, 2023
…o get graalvm native compile compatibility
@Dankosik
Copy link

Да, попробоуй закинуть в BP_NATIVE_IMAGE_BUILD_ARGUMENTS --initialize-at-build-time=ch.qos.logback,org.slf4j.LoggerFactory
Также подключи библиотечку com.google.cloud:native-image-support:0.14.1 они там что-то с netty фиксили

@zscauer
Copy link
Contributor Author

zscauer commented Jun 13, 2023

все равно не собирается) логи spring, quarkus не пробовал.

Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector.reportUntracedLeak(java.lang.String) 
Parsing context:
   at io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector.reportUntracedLeak(ResourceLeakDetector.java:330)
   at io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector.reportLeak(ResourceLeakDetector.java:306)
   at io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector.track0(ResourceLeakDetector.java:262)
   at io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector.track(ResourceLeakDetector.java:245)

@Dankosik
Copy link

Dankosik commented Jun 13, 2023

У меня sring boot - 3.1.0
springCloud - 2022.0..2
И версия плагина для graalVM native image
id("org.graalvm.buildtools.native") version "0.9.22"
Версия graal

OpenJDK Runtime Environment GraalVM CE 22.3.2 (build 17.0.7+7-jvmci-22.3-b18)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.2 (build 17.0.7+7-jvmci-22.3-b18, mixed mode, sharing)
dependencies{
    implementation("com.google.cloud:native-image-support:0.14.1")
}
tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootBuildImage> {
    environment.put("BP_NATIVE_IMAGE_BUILD_ARGUMENTS","--no-fallback --initialize-at-build-time=ch.qos.logback,org.slf4j.LoggerFactory," +
            "org.slf4j.simple.SimpleLogger,org.slf4j.impl.StaticLoggerBinder,org.slf4j.MDC" +
            " -J-Dfile.encoding=UTF-8"
    )
}

Запускаю билд командой ./gradlew bootBuildImage
При чем io.grpc:grpc-netty-shaded:1.44.0 тянется в зависимости, но такой ошибки не ловил
Были какие-то другие с netty, но они пофиксились implementation("com.google.cloud:native-image-support:0.14.1") этим

@Dankosik
Copy link

А у тебя подключено?
implementation("org.springframework.boot:spring-boot-starter-webflux")
Может спринговкие зависимости на netty как-то перезатирают io.grpc:grpc-netty-shaded

@zscauer
Copy link
Contributor Author

zscauer commented Jun 13, 2023

я без клауда, но это решение --initialize-at-build-time=ch.qos.logback,org.slf4j.LoggerFactory,org.slf4j.simple.SimpleLogger,org.slf4j.impl.StaticLoggerBinder,org.slf4j.MDплюс гугловая либа вроде решило проблему, большое спасибо @Dankosik!
На днях оформлю в PR.

zscauer added a commit to zscauer/tinkoff-invest-api-java-sdk-old that referenced this issue Jun 14, 2023
zscauer added a commit to zscauer/tinkoff-invest-api-java-sdk-old that referenced this issue Jun 15, 2023
SRadyukov added a commit that referenced this issue Jul 10, 2023
Fixes #61 change grpc-netty-shaded depende…
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants