Getting "KotlinReflectionInternalError: This callable does not support a default call" error when upgrading to Spring Framework 6 / Tomcat 10
I have a Kotlin application that has worked for a few years in Spring Boot 2.x. Unfortunately, vulnerability scan software at my company picked up an issue with one of the libraries, and the indicated remediation included upgrading to Spring Boot 3 and Spring Framework 6. I also upgraded to Tomcat 10.1.19, as the Spring Framework 6 upgrade documents indicate you need that version of Tomcat for Jakarta (otherwise, none of the web requests work; no error; nothing; just no response whatsoever).
Having done so, there were numerous code changes required to get things to compile, primarily around the change from Javax to Jakarta. Now I am getting the below stack trace.
It seems the issue has to do with attempting to instantiate an entity (ApplicationEntity) for the request. The impression I get is that it's as if it isn't supporting a default constructor for that entity. In the Kotlin code, there is no explicit constructor defined, so I would assume it would use an empty constructor. There is nothing particularly exotic about ApplicationEntity. It is define as a @Bean and has a chain of parent abstract classes marked as @MappedSuperclass. The top-most abstract class contains an @Id field named id, with a @GeneratedValue. Pretty standard stuff.
Has anyone seen anything like this will Spring Boot 3 / Spring Framework 6 / Tomcat 10?
KotlinReflectionInternalError: This callable does not support a default call: @org.springframework.web.bind.annotation.GetMapping public open fun get(@org.springframework.web.bind.annotation.PathVariable id: kotlin.Long, @org.springframework.web.bind.annotation.RequestParam version: com.usbank.fdmt.server.model.type.VersionContextType?, @org.springframework.web.bind.annotation.RequestParam asOf: kotlin.String?): com.usbank.fdmt.server.model.entity.v2.ApplicationEntity defined in com.usbank.fdmt.server.controller.v2.ApplicationEntityController[DeserializedSimpleFunctionDescriptor@3d3bcb3f]
at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:192) ~[kotlin-reflect-1.8.22.jar:1.8.22-release-407(1.8.22)]
at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:111) ~[kotlin-reflect-1.8.22.jar:1.8.22-release-407(1.8.22)]
…
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Please sign in to leave a comment.
Related issue: https://youtrack.jetbrains.com/issue/KT-57357/Reflection-KotlinReflectionInternalError-when-using-callBy-on-constructor-that-has-inline-class-parameter-with-nullable-value.
You can report at https://youtrack.jetbrains.com/newIssue?project=KT
Thanks Serge Baranov for responding! I saw that issue, but it's not immediately obvious to me that it's related. That issue shows a class that is being serialized that has a nullable - but not defaulted - val property named x in it's constructor. The error I'm getting implicates an entity named ApplicationEntity. That class has neither val properties nor explicitly defined constructors, and all member properties have default values provided, so I don't understand how that could be related. The only thing I can guess is it has something to do with the fact that it is a JPA entity class. It has an @Entity annotation, an @ID annotation, various @Column annotations. It's actually an extremely bad idea to serialize Entity classes anyway, because you have to pollute the network of interrelationships with @JsonIgnore annotations and such, so I'm working on a replacement using a DTO (might use a Data Class for that). I'll see if that fixes it.