REST Service fails with MessageBodyWriter not found

Hello,

I try to move a project with REST services from Java to Kotlin.It is a simple Java EE 8 application using JAX-RS. The code is running in the same application (ear file).
The following Java code generates JSON and XML.
java

Converted to Kotlin, JSON still works, XML fails:
k
XML fails with the following message:

[Payara 5.192] [SCHWERWIEGEND] [org.glassfish.jersey.message.internal.WriterInterceptorExecutor] [tid: _ThreadID=48 _ThreadName=http-thread-pool::http-listener-1(3)] [levelValue: 1000] [[
MessageBodyWriter not found for media type=application/xml, type=class java.util.Vector, genericType=java.util.List<? extends xxx.xxx.xxx.xxx.Tapes>.]]

I am out of ideas, can someone help me?

My first thought is that this is the result of a variance problem. Can you try adding @JvmSuppressWildcards as class level annotation as see if that helps? I am unable to confirm if it will work at the moment…
I realise this is a long shot, as a problem with variance would probably affect both content types.

1 Like

Hi,

thanks, @JvmSuppressWildcards works!
The other alternative I found is using Array instead of List. So this needs further investigation, but first I must get the job done.