https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
spring
  • d

    Dany

    05/04/2021, 3:07 PM
    Hi folks! A newbie question (didn't have a lot of background in Java before learning Kotlin). How do I know if there are existing notations annotations to help me to do certain things?
    m
    s
    t
    • 4
    • 6
  • j

    Jacob

    05/05/2021, 8:55 PM
    Anything I should know about before upgrading my spring boot projects to kotlin 1.5.x?
    k
    r
    • 3
    • 3
  • e

    ermac10k

    05/06/2021, 7:44 AM
    Hello! how to benchmark my spring with kotlin service? all internet guides are for java and don’t work for kotlin(
    m
    k
    n
    • 4
    • 6
  • d

    Dennis Schröder

    05/09/2021, 11:48 AM
    I have this simple JPARepository
    interface ProductDAO : JpaRepository<ProductDTO, UUID>
    That I would like to instantiate manually so I can register it via the beans Kotlin DSL like this:
    fun beanDeclarations() = beans {
        bean<ProductDAO>()
        bean<ProductRepository> {
            ProductJPARepository(ref())
        }
        bean<ProductApplicationService> {
            ProductApplicationServiceImpl(ref())
        }
    }
    Could find anything in the interweb … @sdeleuze
    k
    n
    l
    • 4
    • 4
  • m

    Michael Böiers

    05/11/2021, 7:02 AM
    I’ve recently converted a project which uses JPA metamodel generation from Java to Kotlin/JVM. I’m a little worried about using kapt and its issues with newer JDKs - we’re using Java 16, and there kapt only works with a deprecated JDK flag (--illegal-access=permit). Are there better options to generate JPA metamodels in Kotlin?
    • 1
    • 1
  • m

    Mario Ruiz

    05/14/2021, 5:30 AM
    Hi, I'm trying to setup a Spring Cloud Streams app that talks with Kafka, but configuring it has been a nightmare. What I'm trying to do is: have to pipelines made of composing multiple functions. Have separate series for input and output of each pipeline's consumer and producer. Handle schema registry login info. Have a producer pick a topic based on message content.
    :not-kotlin: 3
    s
    • 2
    • 1
  • m

    Mario Ruiz

    05/14/2021, 5:31 AM
    But I've tried pretty much everything I've found online regarding config, and it's a mess. You can configure Kafka in like four different places, and they all have slightly different prop names and types
    s
    • 2
    • 1
  • w

    Wolf Logan

    05/14/2021, 11:16 PM
    I recently discovered (as in "today") that using the
    org.springframework.boot
    Gradle plugin interferes with running JVM tests in my Kotlin MPP project.
    s
    • 2
    • 6
  • m

    marzelwidmer

    05/17/2021, 7:14 PM
    Hello I have a stupid question… 🙂 I get from the
    spring-cloud-gateway-server-3.0.2
    the following message….
    Class 'org.springframework.cloud.gateway.route.builder.RouteDslKt' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
    s
    • 2
    • 5
  • d

    Dany

    05/23/2021, 4:13 PM
    @Configuration / @ConfigurationProperties doesn't work. My application.yml
    seon:
      uri: 123
    My SeonConfiguration class:
    @Configuration
    @ConfigurationProperties(prefix = "seon")
    data class SeonConfiguration(
        var uri: String = ""
    )
    My main class:
    @SpringBootApplication
    @ConfigurationPropertiesScan
    @EnableConfigurationProperties
    class WadzpayServiceApplication
    fun main(args: Array<String>) {
        val seonConfiguration: SeonConfiguration = SeonConfiguration()
        print(seonConfiguration.uri) //this line prints null
        runApplication<WadzpayServiceApplication>(*args)
    }
    I had been looking all the possibile answers on stackoverflow, getting my head crazy but still can't make it work. Any help would be massively appreciated!
    a
    m
    +2
    • 5
    • 17
  • m

    marzelwidmer

    05/27/2021, 6:27 PM
    Hello I was not sure where to ask… https://kotlinlang.slack.com/archives/C1CFAFJSK/p1622140005192900
    s
    t
    +3
    • 6
    • 19
  • n

    Neil

    06/02/2021, 3:16 PM
    What's best practise for processing a lot of SQL rows without loading them all into memory at once? spring-data will return a (java8) Stream but I'm not sure if anything (mysql driver, hibernate, one of kotlin's composable operators) might pull on the Stream and effectively turn it into a List? Alternatively spring-data's pageable can return the data in chunks but I can't see a nice way of iterating around each chunk in a composable manner?
    a
    o
    j
    • 4
    • 7
  • d

    Dennis Schröder

    06/15/2021, 3:53 PM
    How can I inject a property from my
    application.yaml
    in a functional way?
    beans {
        bean {
            Foo(property("foo.bar.buz"))
        }
    }
    i
    t
    • 3
    • 3
  • m

    marzelwidmer

    06/17/2021, 2:59 PM
    I try to configure
    KotlinSerializationJsonEncoder
    in my
    SpringBoot
    app. have maybe somebody a
    hint
    what is wrong in my configuration …. I get the following exception when I call my backend service.
    org.springframework.web.reactive.function.client.WebClientResponseException: 200 OK from UNKNOWN ; nested exception is kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 7: Encountered an unknown key 'fooBar'.
    Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.
    JSON input: {
        "fooBar": "123,345.....
    I try to configured it like this:
    @Configuration
    class WebConfig : WebFluxConfigurer {
        //<https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#webflux-config-message-codecs>
        override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) {
            KotlinSerializationJsonEncoder(
                Json {
                    ignoreUnknownKeys = true
                }
            )
        }
    }
    j
    • 2
    • 2
  • j

    jush

    06/18/2021, 8:35 AM
    We would like to disable Kotlin Serialization and use Jackson until there's streaming support. Is there some way to disable the Kotlin serialization support in Spring? It seems that if we've
    kotlinx.serialization.json.Json
    in our dependencies it is automatically added.
    y
    • 2
    • 3
  • m

    Matthew Adams

    06/18/2021, 8:03 PM
    Does Spring Data
    2021.0.1
    support Kotlin
    1.5
    ? The docs at https://docs.spring.io/spring-data/mongodb/docs/3.2.1/reference/html/#kotlin.requirements say
    Spring Data supports Kotlin 1.3...
    • 1
    • 3
  • e

    EricJTurley

    06/21/2021, 5:35 PM
    ConfigurationProperties - ParameterResolutionException I have:
    @ConfigurationProperties("chat-replay")
    @ConstructorBinding
    data class ChatReplayProperties(
        val chatLogPrintInterval: Long,
        val poll: Poll,
        val generation: Generation,
        val query: Query,
        val external: External,
    ) {
    But: • All the
    chat-replay.generation.*
    properties are in a
    application-genchatlogs.properties
    file, so... • When run with no active Spring Profiles, the
    Generation
    object is
    null
    And application startup fails with
    ParameterResolutionException
    of course. What's a good pattern for this?
    s
    h
    t
    • 4
    • 10
  • d

    Deji

    06/22/2021, 8:10 PM
    Hi all, I am using Spring Webflux and I need some help getting some code to compile
    interface Base
    
    data class Derived(val value: String): Base
    
    fun getDerived(): Mono<Derived> = TODO()
    
    fun getBase(): Mono<Base> = getDerived() // this line does not compile
    
    fun getBase2(): Mono<Base> = getDerived().map { it } // this compiles fine
    I am new to kotlin so I might be missing something. But is it possible to get the 4th line to compile without mapping it again? If this isn’t the right place to ask this please let me know the appropriate channel. Thanks!
    t
    j
    • 3
    • 3
  • l

    Luca Piccinelli

    06/29/2021, 5:58 AM
    Good morning all. Do anyone know if there exist the possibility, with the production ready part of the Spring Kotlin Dsl to make the openAPI plugins work? Or there exist any alternative solution? https://www.baeldung.com/spring-rest-openapi-documentation
    b
    d
    • 3
    • 3
  • h

    holgerbrandl

    07/01/2021, 11:24 AM
    Hi there, when using a nullable
    @JvmInline value class
    value in a thymeleaf template it fails with
    EL1004E: Method call: Method now() cannot be found on type my.org.SimpleFactory
    Is this a known problem? Is a workaround? In the IDE it resolves the method correctly, see the attached screenshot:
    e
    • 2
    • 1
  • n

    nfrankel

    07/02/2021, 12:59 PM
    name your bean and access it as usual your snippet produces anonymous beans
    d
    s
    • 3
    • 4
  • e

    Emil Kantis

    07/06/2021, 10:46 AM
    Is there any official way of caching the result of a
    suspend
    fun? I realize the generated continuation might be creating issues with how the caching mechanism works..
    n
    • 2
    • 3
  • i

    ianbrandt

    07/14/2021, 3:18 PM
    Greetings, I had spring-boot-configuration-processor all working for
    @ConfigurationProperties
    data classes in my project with Kapt, Gradle, and IntelliJ. At some point along the line I started getting a red "Spring Boot Configuration Annotation Processor not configured" banner on my properties classes that wasn't there before. There's at least some association going on. If I add a property to 'application.properties' that's not in my
    @ConfigurationProperties
    class, I do get a "Cannot resolve configuration property" warning on that property. I've created a reproducer here: https://github.com/ianbrandt/spring-kapt I'm fairly certain there were no related changes to my project's configuration other than upgrades of Spring, Kapt, Gradle, and IntelliJ. I'm on the latest release versions of all of the above. Am I missing something that would cause the red IntelliJ banner to now appear where it hadn't before?
    • 1
    • 4
  • d

    Derek Ellis

    07/19/2021, 5:18 PM
    So I've seen that kotlinx serialization can be used just by adding it to the classpath, and that it only handles classes marked with
    @Serializable
    and primitive collections before forwarding everything to Jackson. I've run into an issue where I want to serialize a
    List
    (I believe the implementation is just a regular
    ArrayList
    ) of a serializable class that has some
    @SerialName
    annotations on the properties, but it looks like it's being forwarded to Jackson and the
    @SerialName
    names are being ignored. Is this functionality supported, and how would I update the configuration of my WebFlux project to use kotlinx serialization for this?
    y
    s
    r
    • 4
    • 9
  • j

    Jilles Soeters

    07/28/2021, 11:33 PM
    Any active open source projects using spring/kotlin? Would love to get some inspiration that goes deeper than the Spring Kotlin beginner tutorial
    h
    m
    +2
    • 5
    • 10
  • j

    Jilles Soeters

    07/30/2021, 5:54 PM
    I’ve seen some repositories return
    Iterable<T>
    and others
    List<T>
    . I believe repositories return a
    List
    of entites so why would anyone specify return type of
    Iterable
    ? e.g. https://github.com/spring-guides/tut-spring-boot-kotlin/blob/main/src/main/kotlin/com/example/blog/Repositories.kt#L7
    e
    • 2
    • 1
  • e

    efemoney

    08/02/2021, 9:57 PM
    Whats the standard way to query a graphql API within a kotlin spring boot application. What libraries are there (if any)?
    d
    • 2
    • 11
  • j

    Jilles Soeters

    08/11/2021, 7:23 PM
    While this isn’t strictly a Kotlin Spring question I wonder if anyone knows this: I have a JPA entity that has a lazy relationship. There is one method where I’d like it to be fetched eagerly. In Django for example it’s lazy by default but you can add
    select_related
    to make it eager. Is there a way to load a lazy relationship eagerly in Spring JPA without having to do
    entities.forEach { it.lazy_loaded_attribute }
    or something?
    n
    j
    • 3
    • 5
  • a

    Adrian Cruz

    08/13/2021, 12:56 PM
    👋 hi, ya'll! i'm new to kotlin and spring; i have a REST controller that will be receiving webhooks. we want to validate these webhooks with a signature that gets sent over. we currently have a
    @RequestBody body: MyDataClass
    to get a deserialized object of the payload. but my problem is that i need to pass in the body as a String to validate the signature properly. Is there a proper way to handle this? or do i just update to
    @RequestBody body: String
    , then do validation, and finally do a manual
    ObjectMapper
    to
    MyDataClass
    ?
    t
    t
    +2
    • 5
    • 29
  • m

    marzelwidmer

    08/15/2021, 3:32 PM
    Hello have somebody Kotlin Spring Boot with Native Image
    up&running.
    https://github.com/marzelwidmer/kboot-native
    [INFO]     [creator]       Native Image: Contributing to layer
    [INFO]     [creator]         GraalVM 21.2.0 Java 11 CE (Java Version 11.0.12+6-jvmci-21.2-b08)
    [INFO]     [creator]         Executing native-image -H:+StaticExecutableWithDynamicLibC -H:Name=/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/spring-native-0.10.0.jar:/workspace/BOOT-INF/lib/spring-boot-2.5.3.jar:/workspace/BOOT-INF/lib/spring-context-5.3.9.jar:/workspace/BOOT-INF/lib/spring-aop-5.3.9.jar:/workspace/BOOT-INF/lib/spring-expression-5.3.9.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-2.5.3.jar:/workspace/BOOT-INF/lib/logback-classic-1.2.4.jar:/workspace/BOOT-INF/lib/logback-core-1.2.4.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.14.1.jar:/workspace/BOOT-INF/lib/log4j-api-2.14.1.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-1.7.32.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar:/workspace/BOOT-INF/lib/snakeyaml-1.28.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.12.4.jar:/workspace/BOOT-INF/lib/reactor-netty-http-1.0.9.jar:/workspace/BOOT-INF/lib/netty-codec-http-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-common-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-buffer-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-transport-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-codec-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-handler-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-codec-http2-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-codec-dns-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-native-macos-4.1.66.Final-osx-x86_64.jar:/workspace/BOOT-INF/lib/netty-transport-native-unix-common-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-transport-native-epoll-4.1.66.Final-linux-x86_64.jar:/workspace/BOOT-INF/lib/reactor-netty-core-1.0.9.jar:/workspace/BOOT-INF/lib/netty-handler-proxy-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-codec-socks-4.1.66.Final.jar:/workspace/BOOT-INF/lib/spring-web-5.3.9.jar:/workspace/BOOT-INF/lib/spring-beans-5.3.9.jar:/workspace/BOOT-INF/lib/spring-webflux-5.3.9.jar:/workspace/BOOT-INF/lib/jackson-module-kotlin-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-databind-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-core-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.12.4.jar:/workspace/BOOT-INF/lib/reactor-kotlin-extensions-1.1.3.jar:/workspace/BOOT-INF/lib/reactor-core-3.4.8.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.3.jar:/workspace/BOOT-INF/lib/kotlin-reflect-1.5.21.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-1.5.21.jar:/workspace/BOOT-INF/lib/annotations-13.0.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-common-1.5.21.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-jdk8-1.5.21.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-jdk7-1.5.21.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-reactor-1.5.1.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-reactive-1.5.1.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-core-jvm-1.5.1.jar:/workspace/BOOT-INF/lib/slf4j-api-1.7.32.jar:/workspace/BOOT-INF/lib/spring-core-5.3.9.jar:/workspace/BOOT-INF/lib/spring-jcl-5.3.9.jar:/workspace/BOOT-INF/lib/spring-boot-jarmode-layertools-2.5.3.jar com.example.demo.KbootNativeApplicationKt
    [INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]    classlist:   3,477.37 ms,  1.19 GB
    [INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]        (cap):     523.64 ms,  1.19 GB
    [INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]        setup:   2,577.28 ms,  1.19 GB
    [INFO]     [creator]     To see how the classes got initialized, use --trace-class-initialization=org.springframework.util.unit.DataSize
    [INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]     analysis:  10,754.71 ms,  1.54 GB
    [INFO]     [creator]     Error: Classes that should be initialized at run time got initialized during image building:
    [INFO]     [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
    [INFO]     [creator]
    [INFO]     [creator]     Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
    [INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]      [total]:  17,145.94 ms,  1.54 GB
    [INFO]     [creator]     # Printing build artifacts to: /layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt.build_artifacts.txt
    [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] ------------------------------------------------------------------------
    n
    • 2
    • 4
Powered by Linen
Title
m

marzelwidmer

08/15/2021, 3:32 PM
Hello have somebody Kotlin Spring Boot with Native Image
up&running.
https://github.com/marzelwidmer/kboot-native
[INFO]     [creator]       Native Image: Contributing to layer
[INFO]     [creator]         GraalVM 21.2.0 Java 11 CE (Java Version 11.0.12+6-jvmci-21.2-b08)
[INFO]     [creator]         Executing native-image -H:+StaticExecutableWithDynamicLibC -H:Name=/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/spring-native-0.10.0.jar:/workspace/BOOT-INF/lib/spring-boot-2.5.3.jar:/workspace/BOOT-INF/lib/spring-context-5.3.9.jar:/workspace/BOOT-INF/lib/spring-aop-5.3.9.jar:/workspace/BOOT-INF/lib/spring-expression-5.3.9.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-2.5.3.jar:/workspace/BOOT-INF/lib/logback-classic-1.2.4.jar:/workspace/BOOT-INF/lib/logback-core-1.2.4.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.14.1.jar:/workspace/BOOT-INF/lib/log4j-api-2.14.1.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-1.7.32.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar:/workspace/BOOT-INF/lib/snakeyaml-1.28.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.12.4.jar:/workspace/BOOT-INF/lib/reactor-netty-http-1.0.9.jar:/workspace/BOOT-INF/lib/netty-codec-http-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-common-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-buffer-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-transport-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-codec-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-handler-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-codec-http2-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-codec-dns-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-native-macos-4.1.66.Final-osx-x86_64.jar:/workspace/BOOT-INF/lib/netty-transport-native-unix-common-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-transport-native-epoll-4.1.66.Final-linux-x86_64.jar:/workspace/BOOT-INF/lib/reactor-netty-core-1.0.9.jar:/workspace/BOOT-INF/lib/netty-handler-proxy-4.1.66.Final.jar:/workspace/BOOT-INF/lib/netty-codec-socks-4.1.66.Final.jar:/workspace/BOOT-INF/lib/spring-web-5.3.9.jar:/workspace/BOOT-INF/lib/spring-beans-5.3.9.jar:/workspace/BOOT-INF/lib/spring-webflux-5.3.9.jar:/workspace/BOOT-INF/lib/jackson-module-kotlin-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-databind-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-core-2.12.4.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.12.4.jar:/workspace/BOOT-INF/lib/reactor-kotlin-extensions-1.1.3.jar:/workspace/BOOT-INF/lib/reactor-core-3.4.8.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.3.jar:/workspace/BOOT-INF/lib/kotlin-reflect-1.5.21.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-1.5.21.jar:/workspace/BOOT-INF/lib/annotations-13.0.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-common-1.5.21.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-jdk8-1.5.21.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-jdk7-1.5.21.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-reactor-1.5.1.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-reactive-1.5.1.jar:/workspace/BOOT-INF/lib/kotlinx-coroutines-core-jvm-1.5.1.jar:/workspace/BOOT-INF/lib/slf4j-api-1.7.32.jar:/workspace/BOOT-INF/lib/spring-core-5.3.9.jar:/workspace/BOOT-INF/lib/spring-jcl-5.3.9.jar:/workspace/BOOT-INF/lib/spring-boot-jarmode-layertools-2.5.3.jar com.example.demo.KbootNativeApplicationKt
[INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]    classlist:   3,477.37 ms,  1.19 GB
[INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]        (cap):     523.64 ms,  1.19 GB
[INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]        setup:   2,577.28 ms,  1.19 GB
[INFO]     [creator]     To see how the classes got initialized, use --trace-class-initialization=org.springframework.util.unit.DataSize
[INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]     analysis:  10,754.71 ms,  1.54 GB
[INFO]     [creator]     Error: Classes that should be initialized at run time got initialized during image building:
[INFO]     [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
[INFO]     [creator]
[INFO]     [creator]     Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
[INFO]     [creator]     [/layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt:183]      [total]:  17,145.94 ms,  1.54 GB
[INFO]     [creator]     # Printing build artifacts to: /layers/paketo-buildpacks_native-image/native-image/com.example.demo.KbootNativeApplicationKt.build_artifacts.txt
[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] ------------------------------------------------------------------------
Woop Woop Woop
I found it …. the
Spring AOT plugin
was missing
🙈
n

nfrankel

08/15/2021, 3:55 PM
Error: Classes that should be initialized at run time got initialized during image building:
[INFO]     [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
i’d suggest you to add `
--initialize-at-build-time=org.springframework.util.unit.DataSize
but this is not kotlin related
m

marzelwidmer

08/15/2021, 3:55 PM
.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.3)

2021-08-15 15:54:58.230  INFO 1 --- [           main] o.s.boot.SpringApplication               : Starting application using Java 11.0.12 on df5ff410afff with PID 1 (started by cnb in /workspace)
2021-08-15 15:54:58.230  INFO 1 --- [           main] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2021-08-15 15:54:58.267  INFO 1 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080
2021-08-15 15:54:58.268  INFO 1 --- [           main] o.s.boot.SpringApplication               : Started application in 0.05 seconds (JVM running for 0.052)
I forget to configure the
spring-aot-maven-plugin
<!-- TODO -->
			<plugin>
				<groupId>org.springframework.experimental</groupId>
				<artifactId>spring-aot-maven-plugin</artifactId>
				<version>0.10.2</version>
				<executions>
					<execution>
						<id>test-generate</id>
						<goals>
							<goal>test-generate</goal>
						</goals>
					</execution>
					<execution>
						<id>generate</id>
						<goals>
							<goal>generate</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
View count: 6