Minimal repository with reproduction case: https://github.com/maio/spring-transactional-problem/runs/7580933875

class MyBoolean(var value: Boolean) {
    fun get(): Boolean = value
}

abstract class Foo {
    private val _hasError = MyBoolean(false)
    val hasError: Boolean get() = _hasError.get()
}

@Component
class MyFoo : Foo() {
    @Transactional
    fun whatever() {
    }
}

Calling myFoo.hasError throws NullPointerException which seems wrong.

PS: Repository also contains variants which don't cause this problem (e.g. class without @Transactional and class without usage of base class).

Tested on Spring 2.7.2 with Kotlin 1.7.10 and 1.6.21

Comment From: maio

Person on Kotlin Slack pointed me to https://www.faqcode4u.com/faq/215718/kotlin-instance-variable-is-null-when-accessed-by-spring-proxied-class - adding @Component to abstract class Foo seems to fix the problem.

Comment From: wilkinsona

Thanks for letting us know that you've figured it out. For future reference, this sort of low-level problem is more likely to be a Spring Framework issue than a Spring Boot issue. Spring Boot itself isn't involved in @Transactional and the like – the implementation is entirely in Framework.