Affects: Spring Boot 2.4.4
build.gradle.kts:
...
implementation("org.springframework.boot:spring-boot-starter-rsocket")
...
When one has this:
...
@Controller
@MessageMapping
annotation class RSocketController(
@get:AliasFor(annotation = MessageMapping::class)
val value: String
)
and this:
...
@RSocketController("reader")
class Reader(
private val cellRepository: CellRepository,
) {
@MessageMapping("get-rows-count-in-a-sheet")
suspend fun getRowsCountInASheet(dto: GetRowsCountInASheetDto): Long = coroutineScope {
...
Then one gets the aforementioned (in the subject) exception. But one must say that this:
...
@Validated
@RequestMapping
@RestController
annotation class ApiController(
@get:AliasFor(annotation = RequestMapping::class)
val value: String = ""
)
does not incur any issues.
The stack trace:
...
Caused by: java.lang.annotation.IncompleteAnnotationException: kz.qbi.cells.meta.RSocketController missing element value
at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:83)
at com.sun.proxy.$Proxy77.value(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:266)
at org.springframework.core.annotation.TypeMappedAnnotation.getValue(TypeMappedAnnotation.java:394)
at org.springframework.core.annotation.TypeMappedAnnotation.getValue(TypeMappedAnnotation.java:365)
at org.springframework.core.annotation.TypeMappedAnnotation.getAttributeValue(TypeMappedAnnotation.java:350)
at org.springframework.core.annotation.AbstractMergedAnnotation.getValue(AbstractMergedAnnotation.java:178)
at org.springframework.core.annotation.SynthesizedMergedAnnotationInvocationHandler.lambda$getAttributeValue$1(SynthesizedMergedAnnotationInvocationHandler.java:218)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
at org.springframework.core.annotation.SynthesizedMergedAnnotationInvocationHandler.getAttributeValue(SynthesizedMergedAnnotationInvocationHandler.java:216)
at org.springframework.core.annotation.SynthesizedMergedAnnotationInvocationHandler.invoke(SynthesizedMergedAnnotationInvocationHandler.java:90)
at com.sun.proxy.$Proxy103.value(Unknown Source)
at org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler.getCondition(RSocketMessageHandler.java:313)
at org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler.getMappingForMethod(MessageMappingMessageHandler.java:279)
at org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler.getMappingForMethod(MessageMappingMessageHandler.java:84)
at org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler.lambda$detectHandlerMethods$0(AbstractMethodMessageHandler.java:335)
at org.springframework.core.MethodIntrospector.lambda$selectMethods$0(MethodIntrospector.java:74)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:364)
at org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:72)
at org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler.detectHandlerMethods(AbstractMethodMessageHandler.java:334)
at org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler.initHandlerMethods(AbstractMethodMessageHandler.java:308)
at org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler.afterPropertiesSet(AbstractMethodMessageHandler.java:260)
at org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler.afterPropertiesSet(MessageMappingMessageHandler.java:238)
at org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler.afterPropertiesSet(RSocketMessageHandler.java:286)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782)
... 85 more
Comment From: yerzhant
Tried this:
...
@Controller
@MessageMapping("")
annotation class RSocketController(
@get:AliasFor(annotation = MessageMapping::class)
val value: String = ""
)
didn't help either.
Comment From: snicoll
That looks like a Kotlin issue to me. Have you tried
@get:AliasFor(annotation = MessageMapping::class, attribute = "value")
Comment From: yerzhant
Thanks for the reply. No, I guess I haven't. Actually I'm not working on that project any more. Maybe the issue can be closed as it lost its actuality?
Comment From: snicoll
Alright, given the Kotlin-specific issue and the fact that there are issues that have been fixed in Kotlin in the meantime, I tend to agree. If someone else has the issue with a supported version, we can reopen.