https://kotlinlang.org logo
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
  • c

    cpe

    03/30/2020, 8:38 AM
    Maybe any spring-user already solved this? How do you handle it?
    d
    • 2
    • 2
  • p

    Philipp Mayer

    03/31/2020, 11:33 AM
    Hey guys, does anybody have a hint for me on how to return from the following .onSuccess?
    @GetMapping("/{id}")
        fun getEmployeeById(@PathVariable id: Long): ResponseEntity<EntityModel<Employee>> {
            runCatching { getUseCase.getEmployee(id) }
                    .onFailure { throw ResourceNotFoundException("User with id $id not found.") }
                    .onSuccess {
                        val entityModel = EntityModel(it, linkTo<EmployeeController> { getEmployeeById(id) }.withSelfRel())
                        return ResponseEntity(entityModel, HttpStatus.OK)
                    }
        }
    getUseCase.getEmployee(id)
    can throw an exception that I want to map to an ResourceNotFoundException. I tried to do it in idiomatic Kotlin, but I got stuck at that point. I guess there is another way of achieving this that didn't come up to my mind yet. When there's no exception, the entityModel should be created and returned in an ResponseEntity.
    c
    n
    • 3
    • 5
  • j

    JP

    03/31/2020, 12:25 PM
    As a noob who started learning Kotlin about a month ago (with almost no experience with Java, just skimmed through the Oracle’s Java 8 documentation before jumping into Kotlin) and just started with Spring framework, I want to ask for advice about how I should learn further. I followed the tutorial https://spring.io/guides/tutorials/spring-boot-kotlin/, but of course this just was merely getting a taste of it. Can anyone give some advice how I should further learn about the Spring framework efficiently? Some questions that I had in mind: 1. Is it better to go through Spring Framework’s documentation before going through Spring Boot’s documentation? 2. Is it better to start with simpler frameworks, such as Spring MVC, before jumping into Spring WebFlux?
    a
    m
    c
    • 4
    • 7
  • j

    JP

    04/02/2020, 12:44 PM
    A short question: Which annotation of Spring is handling the conversion between the Kotlin data class object and JSON? Or is this done by some other external library? I made a minimal example with Spring Boot + Kotlin, following this post https://grokonez.com/spring-framework/spring-boot/kotlin-springboot-jquery-ajax-postget. I wanted to learn about AJAX together with Spring Boot. I just changed the jQuery code into vanilla Javascript by myself. I chose in Spring Initializr: • Template Engine -> Thymeleaf (I’m not sure if this was really needed) • Web -> Web (MVC)
    @RestController
    class RestWebController {
    
        val custStore = mutableListOf<Customer>()
    
        @GetMapping("/getallcustomer")
        fun getAllCustomer(): Response {
            println("GET: getallcustomer $custStore")
            return Response("Done", custStore)
        }
    
        @PostMapping("/postcustomer")
        fun postCustomer(@RequestBody customer: Customer): Response {
            println("POST: postcustomer $customer")
            custStore.add(customer)
            return Response("Done", customer)
        }
    }
    data class Response(
        val status: String = "",
        val data : Any
    )
    data class Customer(
        val firstname: String = "",
        val lastname: String = ""
    )
    m
    n
    • 3
    • 6
  • s

    Stian N

    04/06/2020, 8:41 AM
    message has been deleted
    t
    • 2
    • 2
  • d

    dr.dreigh

    04/06/2020, 12:28 PM
    I'm struggling with providing instances of Beans for SpringBoot tests, can anyone see what I'm doing wrong please:
    @SpringBootApplication
    class DemoApplication
    
    fun main(args: Array<String>) {
        runApplication<DemoApplication>(*args)
    }
    
    @Component
    class NormalComponent() {
        fun value() = "Hi"
    }
    Test:
    @TestConfiguration
    class TestConfig {
    
    	@Bean
    	fun normalComponentMock(): NormalComponent {
    		val mock =  mock(NormalComponent::class.java)
    		`when`(mock.value()).thenReturn("I AM A MOCK!")
    		return mock
    	}
    }
    
    @SpringBootTest
    @Import(TestConfig::class)
    class DemoApplicationTests(
    	@Autowired val norm: NormalComponent
    ) {
    	@Test
    	fun normInjectedIntoTest() {
    		assertEquals("I AM A MOCK!", norm.value())
    	}
    }
    The error:
    org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve parameter [com.example.demo.NormalComponent norm] in constructor [public com.example.demo.DemoApplicationTests(com.example.demo.NormalComponent)]: No qualifying bean of type 'com.example.demo.NormalComponent' available: expected single matching bean but found 2: normalComponent,normalComponentMock
    I know I could use
    @MockBean
    - this is just a simple example where the bean I want to inject to the instance. Bit confused why the mock conflict is happening when I have using the
    @TestConfiguration
    and the
    @Import
    annotation - thanks in advance 🙏
    k
    t
    j
    • 4
    • 19
  • s

    Stian N

    04/08/2020, 10:30 AM
    I'm having some issues with using hibernate with Kotlin. I have configured the no-args plugin with JPA https://kotlinlang.org/docs/reference/compiler-plugins.html#jpa-support , but still I get this error
    No default constructor for entity
    . Is there anything else I need to to concider?
    s
    • 2
    • 1
  • p

    Philipp Mayer

    04/08/2020, 2:45 PM
    Hey guys, since I couldn't find anything on the web I thought I might ask you guys: I get the same error in every single spring project I create:
    <build>
            <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
            <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
    Cannot resolve directory '$'{'project.basedir}'
    I guess it's something with my configuration but I just can't point the finger at it. Any ideas? Thanks ahead!
    n
    • 2
    • 6
  • n

    nfrankel

    04/08/2020, 5:32 PM
    next week, i’ll have an online free talk Migrating Spring Boot Config Annotations to Functional Kotlin https://www.meetup.com/Tech-Meetups-ING/events/269742393/
    😱 1
    👍 1
    m
    g
    • 3
    • 2
  • h

    hooliooo

    04/14/2020, 10:46 AM
    How can I access resources in src/main/resources from test?
    :google: 1
    j
    n
    • 3
    • 8
  • d

    Dariusz Kuc

    04/14/2020, 7:43 PM
    hello! what is the preferred way to structure various configuration files, e.g. given some common configuration beans is it better to
    @Configuration @Import([A, B])
    class TopLevelConfig {
      // uses beans from A/B
      // defines beans used commonly by A and B
    }
    or
    @Configuration
    class CommonConfig { // common beans }
    
    @Configuration @Import(CommonConfig)
    class A
    
    @Configuration @Import(CommonConfig)
    class B
    
    @Configuration @Import([A, B])
    class TopLevelConfig { // use beans from A/B }
    m
    s
    • 3
    • 7
  • d

    Dennis Schröder

    04/20/2020, 3:40 PM
    Hey Folks, we are running a little Webflux service in our team. We use
    kotlinx.coroutins.reactor
    package to bridge both worlds (reactive -> Coroutines). Now we want to build an custom
    ReactiveHealthIndicator
    . Therefore we inherit this interface
    ReactiveHealthIndicator
    from
    package org.springframework.boot.actuate.health
    which expects to implement an method with the signature of
    fun health(): Mono<Health>
    . So far, so good. The problem is that we need to call an suspending function Inside the
    health()
    method. Here is a little snippet, which should explain the problem a bit further:
    @Component
    class ClientHealthIndicator(private val client: SomeClient) : ReactiveHealthIndicator {
        private val logger = KotlinLogging.logger { }
        override fun health(): Mono<Health> =
            try {
                client.getPage("home") // THIS IS THE SUSPEND FUNCTION
                Health.up().build().let { Mono.just(it) }
            } catch (e: Exception) {
                logger.error(e) { "ContentClient health check failed" }
                Health.down(e).build().let { Mono.just(it) }
            }
    }
    We tried to use the MonoCoroutine Builder function from
    kotlinx.coroutins.reactor
    to build an scope which returns a Mono.
    @Component
    class ContentClientHealthIndicator(private val contentJsonClient: ContentJsonClient) : ReactiveHealthIndicator {
        private val logger = KotlinLogging.logger { }
        override fun health(): Mono<Health> = mono {
            try {
                contentJsonClient.getPage(it)
                Health.up().build()
            } catch (e: Exception) {
                logger.error(e) { "ContentClient health check failed" }
                Health.down(e).build()
            }
        }
    }
    This does look good, but fails as fullfiling solution because the only thing that get´s catched is this:
    kotlinx.coroutines.JobCancellationException: MonoCoroutine was cancelled
    I am a bit helpless here and would appreciate any help. Thanks in advance Dennis
    n
    a
    • 3
    • 4
  • r

    Robert Jaros

    04/22/2020, 1:59 PM
    I need to send temporary file content with webflux and coroutines, but I want do delete the file after that. Where can I run
    zipFile.delete()
    ? Currently I have this:
    suspend fun download(request: ServerRequest): ServerResponse {
    	val zipFile = // get the temporary <http://java.io|java.io>.File from a different service
    	ServerResponse.ok().contentLength(zipFile.length())
    	.contentType(MediaType.parseMediaType("application/zip"))
            .header("Content-Disposition", "attachment; filename=\"file.zip\"")
            .bodyValueAndAwait(FileSystemResource(zipFile))
    }
    Is there any callback I can use? I don't want to read the file into temporary
    ByteArray
    .
    d
    • 2
    • 8
  • d

    Dariusz Kuc

    04/22/2020, 4:36 PM
    hello! I’m hitting some weird problem with a custom
    BeanPostProcessor
    that my application context fails to load up as it fails to resolve some of the post processor dependencies complaining about unability to parse out
    SPeL
    value passed for one its parameters. My understanding is that Spring post processors should be applied at that point as they are
    PriorityOrdered
    so they take precedence over the regular ordered beans. Using Spring Boot 2.2.5.RELEASE It’s a longshot but just wondering if anyone here hit some similar issue.
    t
    • 2
    • 6
  • a

    Artyom Gornostayev

    04/29/2020, 2:10 PM
    Hey guys. I have a problem with such `RestControllerAdvice`:
    @RestControllerAdvice
    class ExceptionHandlingAdvice {
    
        @ExceptionHandler(NotImplementedError::class)
        fun notImplementedYet(exception: NotImplementedError): ResponseEntity<ErrorResponse> =
            exception.toNotImplementedErrorResponse()
    
        @ExceptionHandler(Throwable::class)
        fun unexpectedException(exception: Throwable): ResponseEntity<ErrorResponse> =
            exception.toInternalServerErrorResponse()
    }
    When I call
    TODO()
    method somewhere in the application the
    kotlin.NotImplementedError
    is occurred. However, the first hadler does not get it. Does anybody has such a problem?
    t
    • 2
    • 3
  • s

    Stian N

    05/06/2020, 2:21 PM
    Are there any guides on how to configure multiple datasources with Kotlin and Spring? I'm trying to follow Java-guide, but I'm having issues with the naming strategy of the Entities. It translates "TableName" to "tablename" instead of "table_name".
    n
    • 2
    • 1
  • e

    EricJTurley

    05/06/2020, 6:10 PM
    I'm trying to use
    testCoroutineScope
    in a
    @SpringBootTest
    . Having trouble. To get started, do you know any examples or docs for this?
    r
    • 2
    • 2
  • s

    Sandy

    05/07/2020, 10:40 PM
    I am using io.github.microutils:kotlin-logging:1.7.6 for logging. I am looking for ways to scrub , hide sensitive data in logs.
    a
    • 2
    • 1
  • t

    Timur Atakishiev

    05/09/2020, 6:31 AM
    Hi guys, I am trying to offer kotlin as a language for next project in my company. I am preparing some presentation about the features of the language. I want to show the real numbers as well something like how many projects from spring initializr have chosen kotlin as a language. Who knows when can I get such information?
    r
    • 2
    • 1
  • d

    Dsittel

    05/26/2020, 1:56 PM
    how to get the body of ServerRequest (in suspend style no bodyToMono) of a dataclass ?
    t
    • 2
    • 2
  • s

    sdeleuze

    05/26/2020, 1:58 PM
    awaitBody()
    https://docs.spring.io/spring-framework/docs/5.2.6.RELEASE/kdoc-api/spring-framework/org.springframework.web.reactive.function.server/index.html
    d
    • 2
    • 8
  • v

    viralshah

    05/27/2020, 2:24 AM
    is it possible to instantiate 2 beans of the same data class eg.
    @Configuration
    class DataSourceConfig {
    
        companion object {
            private val logger = LoggerFactory.getLogger(DataSourceConfig::class.java)
        }
    
        @ConstructorBinding
        @ConfigurationProperties(prefix = "datasource.default")
        data class DefaultDataSource(
            val host: String,
            val port: Int,
            val database: String,
            val username: String,
            val password: String
        ) {
            init {
                <http://logger.info|logger.info>(toString())
            }
        }
    
        @ConstructorBinding
        @ConfigurationProperties(prefix = "datasource.write")
        data class WriteDataSource(
            val host: String,
            val port: Int,
            val database: String,
            val username: String,
            val password: String
        ) {
            init {
                <http://logger.info|logger.info>(toString())
            }
        }
    
        @Bean
        fun defaultFactory(defaultDataSource: DefaultDataSource): ConnectionFactory {
            return ConnectionFactories.get(
                ConnectionFactoryOptions.builder()
                    .option(ConnectionFactoryOptions.DRIVER, "pool")
                    .option(ConnectionFactoryOptions.PROTOCOL, "postgresql")
                    .option(ConnectionFactoryOptions.HOST, defaultDataSource.host)
                    .option(ConnectionFactoryOptions.PORT, defaultDataSource.port)
                    .option(ConnectionFactoryOptions.USER, defaultDataSource.username)
                    .option(ConnectionFactoryOptions.PASSWORD, defaultDataSource.password)
                    .option(ConnectionFactoryOptions.DATABASE, defaultDataSource.database)
                    .build()
            )
        }
    
        @Bean
        fun writeFactory(writeDataSource: WriteDataSource): ConnectionFactory {
            return ConnectionFactories.get(
                ConnectionFactoryOptions.builder()
                    .option(ConnectionFactoryOptions.DRIVER, "pool")
                    .option(
                        ConnectionFactoryOptions.PROTOCOL,
                        "postgresql"
                    )
                    .option(ConnectionFactoryOptions.HOST, writeDataSource.host)
                    .option(ConnectionFactoryOptions.PORT, writeDataSource.port)
                    .option(ConnectionFactoryOptions.USER, writeDataSource.username)
                    .option(ConnectionFactoryOptions.PASSWORD, writeDataSource.password)
                    .option(ConnectionFactoryOptions.DATABASE, writeDataSource.database)
                    .build()
            )
        }
    
    
        @Bean
        @Primary
        fun databaseClient(@Qualifier("defaultFactory") connectionFactory: ConnectionFactory) =
            DatabaseClient.create(connectionFactory)
    
    
        @Bean
        fun writeDatabaseClient(@Qualifier("writeFactory") connectionFactory: ConnectionFactory) =
            DatabaseClient.create(connectionFactory)
    
    }
    Can I clean this up into something that scales when I need to coneect to multiple dbs
    t
    • 2
    • 12
  • k

    kenkyee

    05/28/2020, 10:21 PM
    Nicely done... Love the slices idea 🙂
    s
    • 2
    • 1
  • a

    Anele

    06/01/2020, 3:19 AM
    Hi everyone any idea how to create a json object with json array in your controller? As the example attached
    t
    r
    • 3
    • 6
  • k

    Kepha

    06/09/2020, 12:49 AM
    @sandjelkovic Thank you for your comment : Can your example code be runnable like a daemon in background ?
    s
    • 2
    • 1
  • j

    JP

    06/10/2020, 2:39 PM
    Hi a newbie here learning Kotlin and Spring, and I have some questions regarding writing
    @Entity
    class: 1. Should one NOT use
    data class
    for defining
    @Entity
    class? I’ve found some articles which say that one shouldn’t, but then I’ve also seen many sources just using them. 2. When defining the properties for an
    @Entity
    class, is there a rule to be followed for either using
    val
    or
    var
    ? 3. For
    @Id
    @GeneratedValue
    property, what is the better way to define it: either as a nullable property initialized with
    null
    ? or as a non-nullable property initialized with other dummy value?
    d
    • 2
    • 1
  • s

    sdeleuze

    06/10/2020, 3:25 PM
    Not with Gradle GraalVM integration but good point I should update the Kotlin sample to use Gradle KTS. Could you create an issue for that ? I will take care.
    r
    • 2
    • 1
  • n

    nfrankel

    06/14/2020, 12:42 PM
    but the thing is in most cases you can use the jvm while in development and only use native-image once in a while to check it works
    ☝️ 1
    t
    • 2
    • 2
  • s

    sh3lan

    06/14/2020, 1:03 PM
    hello everyone, i’m a newbie to use kotlin to develop web/backend applications and i didn’t know how to start also, should I be familiar with spring to write web/backend applications using kotin?
    d
    • 2
    • 6
  • j

    JP

    06/15/2020, 11:44 AM
    I am getting an Exception while trying to map the JSON to an object with Jackson.
    com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
     at [Source: (org.apache.catalina.connector.CoyoteInputStream); line: 1, column: 0]
    	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) ~[jackson-databind-2.11.0.jar:2.11.0]
    	at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4624) ~[jackson-databind-2.11.0.jar:2.11.0]
    	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4469) ~[jackson-databind-2.11.0.jar:2.11.0]
    	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3479) ~[jackson-databind-2.11.0.jar:2.11.0]
    	at LoginFilter.attemptAuthentication(LoginFilter.kt:54) ~[main/:na]
    What is the problem? I will put the code snippets in thread
    k
    w
    • 3
    • 4
Powered by Linen
Title
j

JP

06/15/2020, 11:44 AM
I am getting an Exception while trying to map the JSON to an object with Jackson.
com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (org.apache.catalina.connector.CoyoteInputStream); line: 1, column: 0]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) ~[jackson-databind-2.11.0.jar:2.11.0]
	at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4624) ~[jackson-databind-2.11.0.jar:2.11.0]
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4469) ~[jackson-databind-2.11.0.jar:2.11.0]
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3479) ~[jackson-databind-2.11.0.jar:2.11.0]
	at LoginFilter.attemptAuthentication(LoginFilter.kt:54) ~[main/:na]
What is the problem? I will put the code snippets in thread
LoginFilter.kt
UserCredentials.kt
k

kqr

06/15/2020, 1:38 PM
I guess inputstream is already consumed
w

Wesley Acheson

06/24/2020, 5:26 PM
There is another filter for getting values more than once.
View count: 37