question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[3.2.0-M5] UnsupportedOperationException in Kotlin for @Version, @CreatedDate, @LastModifiedDate,

See original GitHub issue

After upgrading from 3.2.0-M4 to 3.2.0-M5 I get the stacktrace below. I’m using Kotlin 1.4.31 and basically have an entity resp. Kotlin data class like this:

data class Kunde(
    val id: UUID?,

    @Version
    val version: Int? = null,

    @CreatedDate
    private val erzeugt: LocalDateTime? = null,

    @LastModifiedDate
    private val aktualisiert: LocalDateTime? = null
)

Using 3.2.0-M5 I have to change all annotated props from val to var. Otherwise I get this stacktrace during insertion for @Version, @CreatedDate and @LastModifiedDate:

java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795)
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:776)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
        at com.acme.kunde.ApplicationKt.main(Application.kt:55)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.UnsupportedOperationException: No accessor to set property @org.springframework.data.annotation.Version()private final java.lang.Integer com.acme.kunde.entity.Kunde.version!
        at com.acme.kunde.entity.Kunde_Accessor_1eaycm.setProperty(Unknown Source)
        at org.springframework.data.mapping.model.InstantiationAwarePropertyAccessor.setProperty(InstantiationAwarePropertyAccessor.java:104)
        at org.springframework.data.mapping.model.ConvertingPropertyAccessor.setProperty(ConvertingPropertyAccessor.java:63)
        at org.springframework.data.mongodb.core.EntityOperations$AdaptibleMappedEntity.initializeVersionProperty(EntityOperations.java:736)
        at org.springframework.data.mongodb.core.ReactiveMongoTemplate.lambda$doInsert$33(ReactiveMongoTemplate.java:1320)
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:113)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1815)
        at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:249)
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:127)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1815)
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151)
        at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:136)
        at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1815)
        at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onComplete(FluxDefaultIfEmpty.java:108)
        at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:142)
        at reactor.core.publisher.Operators.complete(Operators.java:136)
        at reactor.core.publisher.MonoEmpty.subscribe(MonoEmpty.java:45)
        at reactor.core.publisher.Mono.subscribe(Mono.java:4099)
        at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:203)
        at reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53)
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57)
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
        at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:210)
        at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2397)
        at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:110)
        at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
        at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
        at reactor.core.publisher.Mono.subscribe(Mono.java:4099)
        at kotlinx.coroutines.reactive.AwaitKt.awaitOne(Await.kt:137)
        at kotlinx.coroutines.reactive.AwaitKt.awaitOne$default(Await.kt:135)
        at kotlinx.coroutines.reactive.AwaitKt.awaitSingle(Await.kt:81)
        at com.acme.kunde.config.dev.DbPopulate$dbPopulate$1$1$1.invokeSuspend(DbPopulate.kt:163)
        at com.acme.kunde.config.dev.DbPopulate$dbPopulate$1$1$1.invoke(DbPopulate.kt)
        at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit(Collect.kt:134)
        at kotlinx.coroutines.flow.FlowKt__BuildersKt$flowOf$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:114)
        at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect(SafeCollector.common.kt:114)
        at com.acme.kunde.config.dev.DbPopulate$dbPopulate$1$1.invokeSuspend(DbPopulate.kt:155)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at com.acme.kunde.config.dev.DbPopulate$dbPopulate$1.run(DbPopulate.kt:77)
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:792)
        ... 8 more

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
juergenzimmermanncommented, Mar 22, 2021

@mp911de Confirmed. When I use Spring Data Commons 2.5.0-SNAPSHOT as mentioned in https://github.com/spring-projects/spring-data-commons/issues/2336 , the issue is gone.

0reactions
mp911decommented, Mar 22, 2021

That’s a duplicate of spring-projects/spring-data-commons#2336. Let’s move the discussion to the Commons ticket.

The issue is caused by a non-symmetric generics erasure where the Kotlin type (from its primary constructor) resolves to List<InteresseType> while the synthetic copy method resolves to List<?> and we check assignability according to Java rules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnsupportedOperationException - Kotlin Programming ...
Returns a list of stack trace addresses representing the stack trace pertaining to this throwable.
Read more >
[3.2.0-m5]在@version,@createddate,@lastmodifieddate的 ...
[3.2.0-M5] UnsupportedOperationException in Kotlin for @Version, @CreatedDate, @LastModifiedDate,. 从 3.2.0-m4 升级到 3.2.0-M5 ,我得到下面的堆栈。
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found