spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 356 forks source link

Classes that should be initialized at run time got initialized during image building #602

Closed lhmoraes closed 3 years ago

lhmoraes commented 3 years ago
  id("org.springframework.boot") version "2.4.3"
  id("io.spring.dependency-management") version "1.0.11.RELEASE"
  id("org.springframework.experimental.aot") version "0.9.1-SNAPSHOT"

  kotlin("jvm") version "1.4.30"
  kotlin("plugin.spring") version "1.4.30"
  kotlin("kapt") version "1.4.30"

  java.sourceCompatibility = JavaVersion.VERSION_11

Task :mod-rest-app:bootBuildImage Building image 'xxxxxxxxxxxxxxxxxxxxxx:prod-v1.0'

Pulling builder image 'docker.io/paketobuildpacks/builder:tiny' .................................................. Pulled builder image 'paketobuildpacks/builder@sha256:870c2769a65f29c62a0ffe397ae14cc1d61c2e90ebe85f068e8e2fff775c0344' Pulling run image 'docker.io/paketobuildpacks/run:tiny-cnb' .................................................. Pulled run image 'paketobuildpacks/run@sha256:30e7b4b0e1de31e763c7b631161a508c0ef710ea44924f65177afad2644312b9' Executing lifecycle version v0.10.2 Using build cache volume 'pack-cache-f4a4084cdfa4.build'

Running creator [creator] ===> DETECTING [creator] 4 of 11 buildpacks participating [creator] paketo-buildpacks/graalvm 6.0.0 [creator] paketo-buildpacks/executable-jar 5.0.0 [creator] paketo-buildpacks/spring-boot 4.1.0 [creator] paketo-buildpacks/native-image 4.0.0 [creator] ===> ANALYZING [creator] Restoring metadata for "paketo-buildpacks/executable-jar:class-path" from app image [creator] Restoring metadata for "paketo-buildpacks/spring-boot:spring-cloud-bindings" from app image [creator] Restoring metadata for "paketo-buildpacks/spring-boot:web-application-type" from app image [creator] Restoring metadata for "paketo-buildpacks/spring-boot:helper" from app image [creator] ===> RESTORING [creator] ===> BUILDING [creator]
[creator] Paketo GraalVM Buildpack 6.0.0 [creator] https://github.com/paketo-buildpacks/graalvm [creator] Build Configuration: [creator] $BP_JVM_VERSION 11.* the Java version [creator] Launch Configuration: [creator] $BPL_JVM_HEAD_ROOM 0 the headroom in memory calculation [creator] $BPL_JVM_LOADED_CLASS_COUNT 35% of classes the number of loaded classes in memory calculation [creator] $BPL_JVM_THREAD_COUNT 250 the number of threads in memory calculation [creator] $JAVA_TOOL_OPTIONS the JVM launch flags [creator] GraalVM JDK 11.0.10: Contributing to layer [creator] Downloading from https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0.2/graalvm-ce-java11-linux-amd64-21.0.0.2.tar.gz [creator] Verifying checksum [creator] Expanding to /layers/paketo-buildpacks_graalvm/jdk [creator] Adding 129 container CA certificates to JVM truststore [creator] GraalVM Native Image Substrate VM 11.0.10 [creator] Downloading from https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0.2/native-image-installable-svm-java11-linux-amd64-21.0.0.2.jar [creator] Verifying checksum [creator] Installing substrate VM [creator] Processing Component archive: /tmp/24e5a08e2714aee343b22c266285090721ff882ab0a31b7e8e4a68585c38f421/native-image-installable-svm-java11-linux-amd64-21.0.0.2.jar [creator] Installing new component: Native Image (org.graalvm.native-image, version 21.0.0.2) [creator] Writing env.build/JAVA_HOME.override [creator] Writing env.build/JDK_HOME.override [creator]
[creator] Paketo Executable JAR Buildpack 5.0.0 [creator] https://github.com/paketo-buildpacks/executable-jar [creator] Class Path: Contributing to layer [creator] Writing env.build/CLASSPATH.delim [creator] Writing env.build/CLASSPATH.prepend [creator]
[creator] Paketo Spring Boot Buildpack 4.1.0 [creator] https://github.com/paketo-buildpacks/spring-boot [creator] Class Path: Contributing to layer [creator] Writing env.build/CLASSPATH.append [creator] Writing env.build/CLASSPATH.delim [creator] Image labels: [creator] org.springframework.boot.spring-configuration-metadata.json [creator] org.springframework.boot.version [creator]
[creator] Paketo Native Image Buildpack 4.0.0 [creator] https://github.com/paketo-buildpacks/native-image [creator] Build Configuration: [creator] $BP_NATIVE_IMAGE true enable native image build [creator] $BP_NATIVE_IMAGE_BUILD_ARGUMENTS arguments to pass to the native-image command [creator] Native Image: Contributing to layer [creator] GraalVM Version 21.0.0.2 (Java Version 11.0.10+8-jvmci-21.0-b06) [creator] Executing native-image -H:+StaticExecutableWithDynamicLibC -H:Name=/layers/paketo-buildpacks_native-image/native-image/xxxx.ApplicationKt -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/kinder-business-1.0.RELEASE.jar:/workspace/BOOT-INF/lib/kinder-repository-1.0.RELEASE.jar:/workspace/BOOT-INF/lib/kinder-domain-1.0.RELEASE.jar:/workspace/BOOT-INF/lib/milka-4.0.RELEASE.jar:/workspace/BOOT-INF/lib/wavefront-spring-boot-starter-2.1.0.jar:/workspace/BOOT-INF/lib/spring-cloud-starter-sleuth-3.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-starter-kubernetes-client-config-2.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-kubernetes-fabric8-istio-2.0.1.jar:/workspace/BOOT-INF/lib/reactor-kotlin-extensions-1.1.3-SNAPSHOT.jar:/workspace/BOOT-INF/lib/springdoc-openapi-kotlin-1.5.4.jar:/workspace/BOOT-INF/lib/jackson-module-kotlin-2.11.4.jar:/workspace/BOOT-INF/lib/kotlin-reflect-1.4.30.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-reactor-1.4.2.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-jdk8-1.4.30.jar:/workspace/BOOT-INF/lib/loki-logback-appender-1.1.0.jar:/workspace/BOOT-INF/lib/sentry-logback-4.2.0.jar:/workspace/BOOT-INF/lib/mapstruct-1.4.2.Final.jar:/workspace/BOOT-INF/lib/springdoc-openapi-webflux-ui-1.5.4.jar:/workspace/BOOT-INF/lib/commons-io-2.6.jar:/workspace/BOOT-INF/lib/micrometer-registry-prometheus-1.6.4.jar:/workspace/BOOT-INF/lib/mariadb-java-client-2.7.2.jar:/workspace/BOOT-INF/lib/r2dbc-mariadb-1.0.0.jar:/workspace/BOOT-INF/lib/spring-cloud-kubernetes-client-config-2.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-starter-bootstrap-3.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-starter-3.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-kubernetes-client-autoconfig-2.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-kubernetes-fabric8-autoconfig-2.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-kubernetes-commons-2.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-loadbalancer-3.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-kubernetes-test-support-2.0.1.jar:/workspace/BOOT-INF/lib/wavefront-spring-boot-2.1.0.jar:/workspace/BOOT-INF/lib/spring-boot-actuator-autoconfigure-2.4.4-SNAPSHOT.jar:/workspace/BOOT-INF/lib/springdoc-openapi-webflux-core-1.5.4.jar:/workspace/BOOT-INF/lib/springdoc-openapi-common-1.5.4.jar:/workspace/BOOT-INF/lib/client-java-spring-integration-10.0.0.jar:/workspace/BOOT-INF/lib/spring-boot-test-autoconfigure-2.4.4-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-2.4.4-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-boot-actuator-2.4.4-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-boot-test-2.4.4-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-boot-2.4.4-SNAPSHOT.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-jdk7-1.4.30.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-reactive-1.4.2.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-core-jvm-1.4.2.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-1.4.30.jar:/workspace/BOOT-INF/lib/jaxb-api-2.3.1.jar:/workspace/BOOT-INF/lib/jaxb-impl-2.3.1.jar:/workspace/BOOT-INF/lib/jaxb-core-2.3.0.jar:/workspace/BOOT-INF/lib/jackson-dataformat-xml-2.11.4.jar:/workspace/BOOT-INF/lib/istio-client-1.5.5.jar:/workspace/BOOT-INF/lib/istio-model-1.5.5.jar:/workspace/BOOT-INF/lib/client-java-extended-10.0.0.jar:/workspace/BOOT-INF/lib/client-java-10.0.0.jar:/workspace/BOOT-INF/lib/client-java-api-10.0.0.jar:/workspace/BOOT-INF/lib/joda-time-2.10.6.jar:/workspace/BOOT-INF/lib/yavi-0.5.0.jar:/workspace/BOOT-INF/lib/micrometer-registry-wavefront-1.6.4.jar:/workspace/BOOT-INF/lib/micrometer-core-1.6.4.jar:/workspace/BOOT-INF/lib/spring-webflux-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-web-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-data-r2dbc-1.2.6-SNAPSHOT.jar:/workspace/BOOT-INF/lib/r2dbc-pool-0.8.5.RELEASE.jar:/workspace/BOOT-INF/lib/spring-r2dbc-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/r2dbc-spi-0.8.3.RELEASE.jar:/workspace/BOOT-INF/lib/spring-cloud-sleuth-autoconfigure-3.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-sleuth-brave-3.0.1.jar:/workspace/BOOT-INF/lib/reactor-netty-1.0.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/reactor-netty-http-brave-1.0.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/reactor-netty-http-1.0.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/reactor-pool-0.2.3-SNAPSHOT.jar:/workspace/BOOT-INF/lib/reactor-netty-core-1.0.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/reactor-extra-3.4.3-SNAPSHOT.jar:/workspace/BOOT-INF/lib/reactor-core-3.4.4-SNAPSHOT.jar:/workspace/BOOT-INF/lib/kubernetes-client-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-rbac-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-admissionregistration-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-apps-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-autoscaling-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-apiextensions-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-batch-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-certificates-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-coordination-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-discovery-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-events-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-extensions-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-networking-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-metrics-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-policy-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-scheduling-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-settings-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-storageclass-4.10.3.jar:/workspace/BOOT-INF/lib/openshift-model-4.10.3.jar:/workspace/BOOT-INF/lib/kubernetes-model-core-4.10.3.jar:/workspace/BOOT-INF/lib/istio-common-1.5.5.jar:/workspace/BOOT-INF/lib/kubernetes-model-common-4.10.3.jar:/workspace/BOOT-INF/lib/jackson-module-jaxb-annotations-2.11.4.jar:/workspace/BOOT-INF/lib/swagger-integration-2.1.6.jar:/workspace/BOOT-INF/lib/swagger-core-2.1.6.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.11.4.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.11.4.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.11.4.jar:/workspace/BOOT-INF/lib/wavefront-opentracing-sdk-java-2.1.3.jar:/workspace/BOOT-INF/lib/wavefront-runtime-sdk-jvm-1.3.3.jar:/workspace/BOOT-INF/lib/wavefront-internal-reporter-java-1.7.3.jar:/workspace/BOOT-INF/lib/wavefront-sdk-java-2.6.2.jar:/workspace/BOOT-INF/lib/zjsonpatch-0.4.11.jar:/workspace/BOOT-INF/lib/jackson-dataformat-yaml-2.11.4.jar:/workspace/BOOT-INF/lib/jackson-databind-2.11.4.jar:/workspace/BOOT-INF/lib/swagger-models-2.1.6.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.11.4.jar:/workspace/BOOT-INF/lib/logback-classic-1.2.3.jar:/workspace/BOOT-INF/lib/sentry-4.2.0.jar:/workspace/BOOT-INF/lib/swagger-ui-3.42.0.jar:/workspace/BOOT-INF/lib/webjars-locator-core-0.46.jar:/workspace/BOOT-INF/lib/simpleclient_httpserver-0.9.0.jar:/workspace/BOOT-INF/lib/simpleclient_common-0.9.0.jar:/workspace/BOOT-INF/lib/spring-data-relational-2.1.6-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-cloud-sleuth-instrumentation-3.0.1.jar:/workspace/BOOT-INF/lib/spring-context-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-data-commons-2.4.6-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-tx-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-aop-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-beans-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-expression-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-test-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/spring-core-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-common-1.4.30.jar:/workspace/BOOT-INF/lib/annotations-13.0.jar:/workspace/BOOT-INF/lib/javax.activation-api-1.2.0.jar:/workspace/BOOT-INF/lib/jackson-core-2.11.4.jar:/workspace/BOOT-INF/lib/woodstox-core-6.2.3.jar:/workspace/BOOT-INF/lib/stax2-api-4.2.1.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar:/workspace/BOOT-INF/lib/snakeyaml-1.27.jar:/workspace/BOOT-INF/lib/HdrHistogram-2.1.12.jar:/workspace/BOOT-INF/lib/LatencyUtils-2.0.3.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.13.3.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-1.7.30.jar:/workspace/BOOT-INF/lib/jose4j-0.7.2.jar:/workspace/BOOT-INF/lib/json-path-2.4.0.jar:/workspace/BOOT-INF/lib/slf4j-api-1.7.30.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.3.jar:/workspace/BOOT-INF/lib/spring-cloud-context-3.0.1.jar:/workspace/BOOT-INF/lib/spring-cloud-commons-3.0.1.jar:/workspace/BOOT-INF/lib/spring-security-rsa-1.0.9.RELEASE.jar:/workspace/BOOT-INF/lib/aspectjweaver-1.9.6.jar:/workspace/BOOT-INF/lib/aspectjrt-1.9.6.jar:/workspace/BOOT-INF/lib/brave-context-slf4j-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-spring-rabbit-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-kafka-streams-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-kafka-clients-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-jms-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-messaging-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-rpc-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-httpclient-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-httpasyncclient-5.13.2.jar:/workspace/BOOT-INF/lib/brave-instrumentation-mongodb-5.13.2.jar:/workspace/BOOT-INF/lib/brave-propagation-aws-0.21.3.jar:/workspace/BOOT-INF/lib/brave-instrumentation-http-5.13.2.jar:/workspace/BOOT-INF/lib/brave-5.13.2.jar:/workspace/BOOT-INF/lib/zipkin-reporter-metrics-micrometer-2.16.1.jar:/workspace/BOOT-INF/lib/javax.annotation-api-1.3.2.jar:/workspace/BOOT-INF/lib/guava-29.0-jre.jar:/workspace/BOOT-INF/lib/jsr305-3.0.2.jar:/workspace/BOOT-INF/lib/logback-core-1.2.3.jar:/workspace/BOOT-INF/lib/gson-fire-1.8.4.jar:/workspace/BOOT-INF/lib/gson-2.8.6.jar:/workspace/BOOT-INF/lib/swagger-annotations-2.1.6.jar:/workspace/BOOT-INF/lib/classgraph-4.8.69.jar:/workspace/BOOT-INF/lib/commons-lang3-3.11.jar:/workspace/BOOT-INF/lib/simpleclient-0.9.0.jar:/workspace/BOOT-INF/lib/spring-jcl-5.3.5-SNAPSHOT.jar:/workspace/BOOT-INF/lib/jakarta.xml.bind-api-2.3.3.jar:/workspace/BOOT-INF/lib/jakarta.activation-api-1.2.2.jar:/workspace/BOOT-INF/lib/netty-codec-http2-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-handler-proxy-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-codec-http-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-native-macos-4.1.59.Final-osx-x86_64.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-transport-native-epoll-4.1.59.Final-linux-x86_64.jar:/workspace/BOOT-INF/lib/spring-security-crypto-5.4.5.jar:/workspace/BOOT-INF/lib/bcpkix-jdk15on-1.66.jar:/workspace/BOOT-INF/lib/spring-cloud-sleuth-api-3.0.1.jar:/workspace/BOOT-INF/lib/zipkin-reporter-2.16.1.jar:/workspace/BOOT-INF/lib/client-java-proto-10.0.0.jar:/workspace/BOOT-INF/lib/commons-codec-1.15.jar:/workspace/BOOT-INF/lib/commons-compress-1.20.jar:/workspace/BOOT-INF/lib/bcprov-ext-jdk15on-1.66.jar:/workspace/BOOT-INF/lib/protobuf-java-3.13.0.jar:/workspace/BOOT-INF/lib/commons-collections4-4.4.jar:/workspace/BOOT-INF/lib/bucket4j-core-4.10.0.jar:/workspace/BOOT-INF/lib/junit-jupiter-5.7.1.jar:/workspace/BOOT-INF/lib/junit-jupiter-engine-5.7.1.jar:/workspace/BOOT-INF/lib/junit-platform-engine-1.7.1.jar:/workspace/BOOT-INF/lib/mockito-junit-jupiter-3.6.28.jar:/workspace/BOOT-INF/lib/junit-jupiter-params-5.7.1.jar:/workspace/BOOT-INF/lib/junit-jupiter-api-5.7.1.jar:/workspace/BOOT-INF/lib/junit-platform-commons-1.7.1.jar:/workspace/BOOT-INF/lib/junit-vintage-engine-5.7.1.jar:/workspace/BOOT-INF/lib/awaitility-4.0.3.jar:/workspace/BOOT-INF/lib/logging-interceptor-3.14.4.jar:/workspace/BOOT-INF/lib/okhttp-3.14.4.jar:/workspace/BOOT-INF/lib/zjsonpatch-0.3.0.jar:/workspace/BOOT-INF/lib/generex-1.0.2.jar:/workspace/BOOT-INF/lib/joda-convert-2.2.1.jar:/workspace/BOOT-INF/lib/antlr4-runtime-4.7.1.jar:/workspace/BOOT-INF/lib/netty-handler-4.1.59.Final.jar:/workspace/BOOT-INF/lib/log4j-api-2.13.3.jar:/workspace/BOOT-INF/lib/netty-codec-dns-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-codec-socks-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-codec-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-transport-native-unix-common-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-transport-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-buffer-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-4.1.59.Final.jar:/workspace/BOOT-INF/lib/netty-common-4.1.59.Final.jar:/workspace/BOOT-INF/lib/zipkin-2.23.0.jar:/workspace/BOOT-INF/lib/jakarta.el-3.0.3.jar:/workspace/BOOT-INF/lib/hibernate-validator-6.1.7.Final.jar:/workspace/BOOT-INF/lib/bcprov-jdk15on-1.66.jar:/workspace/BOOT-INF/lib/builder-annotations-0.22.0.jar:/workspace/BOOT-INF/lib/swagger-annotations-1.6.2.jar:/workspace/BOOT-INF/lib/failureaccess-1.0.1.jar:/workspace/BOOT-INF/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/workspace/BOOT-INF/lib/checker-qual-2.11.1.jar:/workspace/BOOT-INF/lib/error_prone_annotations-2.3.4.jar:/workspace/BOOT-INF/lib/j2objc-annotations-1.3.jar:/workspace/BOOT-INF/lib/assertj-core-3.18.1.jar:/workspace/BOOT-INF/lib/junit-4.13.2.jar:/workspace/BOOT-INF/lib/hamcrest-core-2.2.jar:/workspace/BOOT-INF/lib/hamcrest-2.2.jar:/workspace/BOOT-INF/lib/mockito-core-3.6.28.jar:/workspace/BOOT-INF/lib/jsonassert-1.5.0.jar:/workspace/BOOT-INF/lib/xmlunit-core-2.7.0.jar:/workspace/BOOT-INF/lib/apiguardian-api-1.1.0.jar:/workspace/BOOT-INF/lib/okio-1.17.2.jar:/workspace/BOOT-INF/lib/automaton-1.11-8.jar:/workspace/BOOT-INF/lib/jakarta.validation-api-2.0.2.jar:/workspace/BOOT-INF/lib/jboss-logging-3.4.1.Final.jar:/workspace/BOOT-INF/lib/classmate-1.5.1.jar:/workspace/BOOT-INF/lib/sundr-core-0.22.0.jar:/workspace/BOOT-INF/lib/sundr-codegen-0.22.0.jar:/workspace/BOOT-INF/lib/resourcecify-annotations-0.22.0.jar:/workspace/BOOT-INF/lib/json-smart-2.3.jar:/workspace/BOOT-INF/lib/byte-buddy-1.10.20.jar:/workspace/BOOT-INF/lib/byte-buddy-agent-1.10.20.jar:/workspace/BOOT-INF/lib/objenesis-3.1.jar:/workspace/BOOT-INF/lib/android-json-0.0.20131108.vaadin1.jar:/workspace/BOOT-INF/lib/opentest4j-1.2.0.jar:/workspace/BOOT-INF/lib/accessors-smart-1.2.jar:/workspace/BOOT-INF/lib/asm-5.0.4.jar xxxx.ApplicationKt [creator] [/layers/paketo-buildpacks_native-image/native-image/xxxx.ApplicationKt:156] classlist: 29,997.89 ms, 1.64 GB [creator] [/layers/paketo-buildpacks_native-image/native-image/xxxx.ApplicationKt:156] (cap): 1,200.82 ms, 1.64 GB [creator] [/layers/paketo-buildpacks_native-image/native-image/xxxx.ApplicationKt:156] setup: 5,785.50 ms, 1.64 GB [creator] To see how the classes got initialized, use --trace-class-initialization=org.springframework.util.unit.DataSize [creator] [/layers/paketo-buildpacks_native-image/native-image/xxxx.ApplicationKt:156] analysis: 25,203.63 ms, 1.62 GB [creator] Error: Classes that should be initialized at run time got initialized during image building: [creator] org.springframework.util.unit.DataSize was unintentionally initialized at build time. To see why org.springframework.util.unit.DataSize got initialized use --trace-class-initialization=org.springframework.util.unit.DataSize [creator]
[creator] Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception [creator] Error: Image build request failed with exit status 1
[creator] unable to invoke layer creator [creator] unable to contribute native-image layer [creator] error running build [creator] exit status 1 [creator] ERROR: failed to build: exit status 1

Task :mod-rest-app:bootBuildImage FAILED

Execution failed for task ':mod-rest-app:bootBuildImage'.

Builder lifecycle 'creator' failed with status code 145

MarcelCoding commented 3 years ago

Have a look here: https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#_datasize_was_unintentionally_initialized_at_build_time

lhmoraes commented 3 years ago

Thanks @MarcelCoding

Added the dependency:

implementation("org.springframework.experimental:spring-native:0.9.0")

But I'm still getting the same error:

    [creator]     Error: Classes that should be initialized at run time got initialized during image building:
    [creator]      org.springframework.util.unit.DataSize was unintentionally initialized at build time. To see why org.springframework.util.unit.DataSize got initialized use --trace-class-initialization=org.springframework.util.unit.DataSize
MarcelCoding commented 3 years ago

You also need the aot plugin https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#spring-aot-gradle

lhmoraes commented 3 years ago

Yes, its already there:

id("org.springframework.experimental.aot") version "0.9.0"

MarcelCoding commented 3 years ago

Yes, its already there:

id("org.springframework.experimental.aot") version "0.9.0"

Ohh, sorry I missed it. Do you have you project on a public GitHub repository or something similar?

lhmoraes commented 3 years ago

No, sorry, that is a private repo, a project from my company, but I can provide some information that you need

bclozel commented 3 years ago

@lhmoraes I'm sorry but in this case the devil is in the details. It looks like this is a multi-module project. We already fixed a similar issue and the actual source of the problem can be really hard to diagnose by comments in an issue.

Could you create a minimal, sample project that reproduces this behavior? Given that the AOT processing doesn't seem to be involved at all this should be obvious once it's ready. Copying the multi-module aspect of the build and possibly build plugins involved should be a good start.

Thanks!

lhmoraes commented 3 years ago

You are correct @bclozel its a multi-module project, please see below my main and modules build.gradle:

Main build.gradle.kts

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
import org.jetbrains.kotlin.kapt3.base.Kapt.kapt

plugins {
    id("org.springframework.boot") version "2.4.3"
    id("io.spring.dependency-management") version "1.0.11.RELEASE"
    id("org.springframework.experimental.aot") version "0.9.0"

    kotlin("jvm") version "1.4.30"
    kotlin("plugin.spring") version "1.4.30"
    kotlin("kapt") version "1.4.30"

    base
    java
}

allprojects {

    // Apply plugins for the all sub-projects .......................
    apply(plugin = "java")
    apply(plugin = "base")
    apply(plugin = "kotlin")
    apply(plugin = "kotlin-spring")
    apply(plugin = "kotlin-kapt")
    apply(plugin = "org.springframework.boot")
    apply(plugin = "io.spring.dependency-management")

    // Project configuration ........................................
    val PROJECT_GROUP                = "xxxxxxxxx"
    val PROJECT_VERSION              = "1.0.RELEASE"
    val SPRING_CLOUD_VERSION         = "2020.0.1"
    val SPRING_DOC_OPENAPI_VERSION   = "1.5.4"
    val COMMON_VERSION         = "4.0.RELEASE"
    val MAPSTRUCT_VERSION            = "1.4.2.Final"
    val SENTRY_VERSION               = "4.2.0"
    val R2DBC_MARIADB_VERSION        = "1.0.0"
    val WAVEFRONT_VERSION            = "2.1.0"
    val LOKI_VERSION                 = "1.1.0"
    val JODA_VERSION                 = "2.10.1"

    val IMAGE_NAME        = "xxxxxxxxx"
    val REGISTRY_URL      = "xxxxxxxxx"
    val REGISTRY_USERNAME = "xxxxxxxxx"
    val REGISTRY_PASSWORD = "xxxxxxxxx"
    val REGISTRY_CONTACT  = "xxxxxxxxx"

    // Project group and version configuration .......................
    group   = PROJECT_GROUP!!
    version = PROJECT_VERSION!!

    base.archivesBaseName    = rootProject.name
    java.sourceCompatibility = JavaVersion.VERSION_11

    // Dependencies Libraries .........................................
    dependencies {

        // Company Common Lib .................
        implementation("xxxxxxxxxxxx:${COMMON_VERSION}")

        // Spring Framework ..........
        implementation("org.springframework.boot:spring-boot-starter-actuator")
        implementation("org.springframework.boot:spring-boot-starter-webflux")
        implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
        implementation("org.springframework.cloud:spring-cloud-starter-sleuth")
        developmentOnly("org.springframework.boot:spring-boot-devtools")

        // Spring Native Image ..............
        implementation("org.springframework.experimental:spring-native:0.9.0")

        // Spring Kubernetes ................
        implementation("org.springframework.cloud:spring-cloud-starter-kubernetes-client-config")
        implementation("org.springframework.cloud:spring-cloud-kubernetes-fabric8-istio")

        // Kotlin ....................
        implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
        implementation("org.jetbrains.kotlin:kotlin-reflect")
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
        implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")

        // Micrometer Prometheus ......
        runtimeOnly("io.micrometer:micrometer-registry-prometheus")

        // Jackson ...................
        implementation("com.fasterxml.jackson.module:jackson-module-kotlin")

        // Wavefront .................
        implementation("com.wavefront:wavefront-spring-boot-starter")

        // MariaDB ...................
        runtimeOnly("org.mariadb.jdbc:mariadb-java-client")
        runtimeOnly("org.mariadb:r2dbc-mariadb:${R2DBC_MARIADB_VERSION}")

        // Loki Grafana Logging.......
        implementation ("com.github.loki4j:loki-logback-appender:${LOKI_VERSION}")

        // Sentry ....................
        implementation("io.sentry:sentry-logback:${SENTRY_VERSION}")

        // MapStruct .................
        implementation("org.mapstruct:mapstruct:${MAPSTRUCT_VERSION}")
        kapt("org.mapstruct:mapstruct-processor:${MAPSTRUCT_VERSION}")

        // Joda Date Time ..............
        //implementation("joda-time:joda-time:${JODA_VERSION}")

        // SpringDoc-OpenApi .........
        implementation("org.springdoc:springdoc-openapi-webflux-ui:${SPRING_DOC_OPENAPI_VERSION}")
        implementation("org.springdoc:springdoc-openapi-kotlin:${SPRING_DOC_OPENAPI_VERSION}")

        // Apache Commons ............
        implementation("commons-io:commons-io:2.6")

        // Spring Test ...............
        testImplementation("org.springframework.boot:spring-boot-starter-test")
        testImplementation("io.projectreactor:reactor-test")
    }

    // Spring Cloud dependency management .....................................
    dependencyManagement {
        imports {
            mavenBom("org.springframework.cloud:spring-cloud-dependencies:${SPRING_CLOUD_VERSION}")
            mavenBom("com.wavefront:wavefront-spring-boot-bom:${WAVEFRONT_VERSION}")
        }
    }

    // Dependencies repositories .....................................
    repositories {
        maven { url = uri( "https://repo.spring.io/release") }
        maven { url = uri( "https://repo.spring.io/milestone") }
        maven { url = uri( "https://repo.spring.io/snapshot") }
        mavenCentral()
    }

    // Tasks ..................................................................
    tasks {
        withType<Test> {
            useJUnitPlatform()
        }

        withType<KotlinCompile> {
            kotlinOptions {
                freeCompilerArgs = listOf("-Xjsr305=strict")
                jvmTarget = java.sourceCompatibility.toString()
            }
        }

        // Image: Build the image and publish it to the private parlacom registry
        withType<BootBuildImage> {
            builder = "paketobuildpacks/builder:tiny"
            environment = mapOf("BP_NATIVE_IMAGE" to "true")

            imageName = IMAGE_NAME
            isPublish = true

            docker {
                publishRegistry {
                    username = REGISTRY_USERNAME
                    password = REGISTRY_PASSWORD
                    url      = REGISTRY_URL
                    email    = REGISTRY_CONTACT
                }
            }
        }
    }
}

Module build.gradle.kts

import org.springframework.boot.gradle.tasks.bundling.BootJar

    // Module group and version configuration .................................
    base.archivesBaseName = "${rootProject.name}-${project.name.substring(4)}"

    // Tasks ..................................................................
    tasks.getByName<BootJar>("bootJar") {
        enabled = false
    }

    tasks.getByName<Jar>("jar") {
        enabled = true
    }
bclozel commented 3 years ago

Interesting.

Any particular reason behind the bootJar task being disabled by your build? Currently our build plugin is relying on that task to package the AOT generated classes with the application. This would explain why they're missing when we're building the container image.

Could you try and activate it to check whether this fixes the problem?

lhmoraes commented 3 years ago

@bclozel enabled it, but I'm getting the same error:

tasks.getByName<BootJar>("bootJar") {
     enabled = true
}

Error:

[creator]     Error: Classes that should be initialized at run time got initialized during image building:
[creator]      org.springframework.util.unit.DataSize was unintentionally initialized at build time. To see why org.springframework.util.unit.DataSize got initialized use --trace-class-initialization=org.springframework.util.unit.DataSize
bclozel commented 3 years ago

In this case, we're definitely going to need a sample project that we can clone or download so that we can work on this.

lhmoraes commented 3 years ago

Thanks @bclozel I will create a sample project and publish it in a public repository

lhmoraes commented 3 years ago

Hi @bclozel I've pushed a sample project that describes the error. Please, just execute bootBuildImage to simulate the issue.

https://github.com/lhmoraes/sb-native-image

Thanks and just let me know if you need more information.

bclozel commented 3 years ago

Thanks @lhmoraes for the sample. Unfortunately it wasn't really minimal, so there was a lot to unpack here.

First, the "org.springframework.experimental.aot" plugin was only applied on the parent project, but not on the actual module that builds the Spring Boot application and the docker image. Applying it to the right module would solve the main problem here.

As a general feedback, the Spring Boot plugin should only be applied on the module where the main class lives. Same for the AOT plugin, which is a companion plugin in this case.

Also, the sample was depending on Spring Boot devtools (see #532) and Sleuth (see #135) - they're not supported yet.

The sample also depends on Spring Cloud Kubernetes, bringing OkHttp (requiring UTF-32BE encoding) and using HttpStatus reflection in some other part (see #612). Both problems can be solved with the following annotations on the main class:

@NativeHint(options = ["-H:+AddAllCharsets"])
@TypeHint(types = [HttpStatus::class])

Of course, it's hard to figure out the changes from this comment. I've submitted a PR to your sample that moves things forward. This might need a bit more work but I think we've covered the main report here.

Besides all the linked issues here, we'll help developers with multi-module projects with a sample in #611. I'm closing this issue for now since other, more focused issues, are already covering things.

Thanks!

lhmoraes commented 3 years ago

Thanks @bclozel it's much better now, I will continue to work on the issues

nekperu15739 commented 3 years ago

Hi, i see that my poc is pretty similar to mentioned on this issue, however, i dont know why its throwing 145 on build, i raised me to 12GB, however still happing, could you take a look?

[INFO] [creator] at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) [INFO] [creator] Error: Image build request failed with exit status 1 [INFO] [creator] unable to invoke layer creator [INFO] [creator] unable to contribute native-image layer [INFO] [creator] error running build [INFO] [creator] exit status 1 [INFO] [creator] ERROR: failed to build: exit status 1 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 05:45 min [INFO] Finished at: 2021-05-24T23:49:40+02:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.5:build-image (default-cli) on project anagram: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.5:build-image failed: Builder lifecycle 'creator' failed with status code 145 -> [Help 1] [ERROR]

repo: https://github.com/nekperu15739/anagram/tree/feature/kuberneter

sdeleuze commented 3 years ago

@nekperu15739 I can build it without an issue on my computer, and it shows the following error:

The bean 'anagramHandler' could not be injected as a 'com.nekperu15739.anagram.handler.AnagramHandler' because it is a JDK dynamic proxy that implements