Most probably, you have kotlinx-serialization as a transitive dependency, and have a version clash somewhere; 0.20.0 vs 1.0.0 etc. seems to be the common root of this problem.
I am running into the same issue for spring boot version 2.7.9.
kotlinx-serialization-json is not a dependency for my project either and I was unable to find any transitive dependencies in my project’s pom or parent poms as well.
I have tried adding explicit exclusions for that dependency in my poms and also later tried to add the dependency to specify the version directly. Looking at my .m2 folder, I do not see kotlinx-serialization-json being pulled in when I build my project either.
I have also tried utilizing the maven enforcer plug-in to make sure that the dependency does not exist in my app.
Any other leads to try and fix this issue would be greatly appreciated!
2023-01-23 16:01:41.773 WARN 11895 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/springframework/http/converter/json/KotlinSerializationJsonHttpMessageConverter.<init>()V @4: invokespecial
Reason:
Type 'kotlinx/serialization/json/Json$Default' (current frame, stack[1]) is not assignable to 'kotlinx/serialization/json/Json'
Current Frame:
bci: @4
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, 'kotlinx/serialization/json/Json$Default' }
Bytecode:
0x0000000: 2ab2 0001 b700 02b1
2023-01-23 16:01:41.799 INFO 11895 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-01-23 16:01:41.843 ERROR 11895 --- [ main] o.s.boot.SpringApplication : Application run failed```