Kotlin: `javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type`
See original GitHub issueDescribe the bug
@ApplicationScoped
class ConfigManager {
@ConfigProperty(name = "hasura.graphql.admin.secret")
lateinit var hasuraAdminSecret: Optional<String>
@ConfigProperty(name = "hasura.graphql.endpoint", defaultValue = "http://localhost:8080")
lateinit var hasuraEndpoint: String
}
/*******************************************************/
interface HasuraAPI {
@POST
@Path("/v1/metadata")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
fun metadataRequest(payload: MetadataQueryPayload): ObjectNode // Jackson JSON object
}
@ApplicationScoped
class HasuraAPIClient {
@Inject lateinit var configManager: ConfigManager
val client: HasuraAPI by lazy {
RestClientBuilder.newBuilder()
.baseUri(URI(configManager.hasuraEndpoint))
.build(HasuraAPI::class.java)
}
fun exportMetadata(): ObjectNode {
val payload = MetadataQueryPayload(
type = "export_metadata",
args = ObjectMapper().createObjectNode()
)
return client.metadataRequest(payload)
}
}
class MetadataQueryPayload(
@JsonProperty("type") val type: String,
@JsonProperty("args") val args: ObjectNode,
@JsonProperty("version") val version: Int? = 2
)
/*******************************************************/
@QuarkusTest
internal class HasuraAPIClientTest {
@Inject
lateinit var client: HasuraAPIClient
@Test
fun `export metadata works`() {
val response = client.exportMetadata()
expect {
that(response).isA<ObjectNode>()
that(response["metadata"]["version"]).isA<Int>()
}
}
}
Expected behavior
This succeeds (or it tells me what I’m doing wrong in language so simple even I can understand it😅)
Actual behavior
Running Gradle on WSL...
INFO: Installed features: [cdi, config-yaml, jaxrs-client-reactive, kotlin, qute, rest-client, rest-client-mutiny, rest-client-reactive, rest-client-reactive-jackson, resteasy-reactive, resteasy-reactive-jackson, resteasy-reactive-qute, smallrye-context-propagation, smallrye-health, vertx]
RESTEASY004655: Unable to invoke request: javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type: org.hasura.MetadataQueryPayload
javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request: javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type: org.hasura.MetadataQueryPayload
at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.invoke(ManualClosingApacheHttpClient43Engine.java:299)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:494)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invokeSync(ClientInvoker.java:152)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:115)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76)
at jdk.proxy6/jdk.proxy6.$Proxy65.metadataRequest(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at
org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type: org.hasura.MetadataQueryPayload
at org.jboss.resteasy.core.interception.jaxrs.ClientWriterInterceptorContext.throwWriterNotFoundException(ClientWriterInterceptorContext.java:50)
at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.getWriter(AbstractWriterInterceptorContext.java:302)
at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.syncProceed(AbstractWriterInterceptorContext.java:240)
at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:224)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.writeRequestBody(ClientInvocation.java:446)
at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.writeRequestBodyToOutputStream(ManualClosingApacheHttpClient43Engine.java:603)
at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.buildEntity(ManualClosingApacheHttpClient43Engine.java:562)
at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.loadHttpMethod(ManualClosingApacheHttpClient43Engine.java:467)
at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.invoke(ManualClosingApacheHttpClient43Engine.java:277)
... 106 more
HasuraAPIClientTest > export metadata works() FAILED
javax.ws.rs.ProcessingException at HasuraAPIClientTest.kt:18
Caused by: javax.ws.rs.ProcessingException at HasuraAPIClientTest.kt:18
Jul 18, 2021 10:52:58 PM io.quarkus.bootstrap.runner.Timing printStopTime
INFO: Quarkus stopped in 0.023s
Jul 18, 2021 10:52:58 PM org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine finalize
WARN: RESTEASY004687: Closing a class org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine instance for you. Please close clients yourself.
How to Reproduce?
Code above is set up with Graal 21.3.0-dev JDK16
and the following Gradle deps, from the latest (2.1.0-CR1) release of Quarkus:
plugins {
val kotlinVersion = "1.5.20"
kotlin("jvm") version kotlinVersion
kotlin("kapt") version kotlinVersion
kotlin("plugin.allopen") version kotlinVersion
id("org.jlleitschuh.gradle.ktlint") version "10.1.0"
id("io.quarkus")
}
repositories {
mavenCentral()
mavenLocal()
}
val quarkusPlatformGroupId: String by project
val quarkusPlatformArtifactId: String by project
val quarkusPlatformVersion: String by project
dependencies {
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
implementation("io.quarkus:quarkus-arc")
implementation("io.quarkus:quarkus-config-yaml")
implementation("io.quarkus:quarkus-container-image-docker")
implementation("io.quarkus:quarkus-jaxrs-client-reactive")
implementation("io.quarkus:quarkus-kotlin")
implementation("io.quarkus:quarkus-mutiny")
implementation("io.quarkus:quarkus-rest-client-mutiny")
implementation("io.quarkus:quarkus-rest-client-reactive")
implementation("io.quarkus:quarkus-rest-client-reactive-jackson")
implementation("io.quarkus:quarkus-resteasy-reactive")
implementation("io.quarkus:quarkus-resteasy-reactive-jackson")
implementation("io.quarkus:quarkus-resteasy-reactive-qute")
implementation("io.quarkus:quarkus-smallrye-health")
implementation("io.quarkus:quarkus-vertx")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.0")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.3")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("io.vertx:vertx-lang-kotlin:4.1.1")
implementation("io.vertx:vertx-lang-kotlin-coroutines:4.1.1")
implementation("org.rauschig:jarchivelib:1.1.0")
// Test Dependencies
testImplementation("io.quarkus:quarkus-junit5")
testImplementation("io.rest-assured:rest-assured")
testImplementation("io.rest-assured:kotlin-extensions")
testImplementation(platform("io.strikt:strikt-bom:0.31.0"))
testImplementation("io.strikt:strikt-core")
testImplementation("io.strikt:strikt-jvm")
testImplementation("org.testcontainers:testcontainers:1.15.3")
testImplementation("org.testcontainers:junit-jupiter:1.15.3")
}
java {
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
}
allOpen {
annotation("javax.ws.rs.Path")
annotation("javax.enterprise.context.ApplicationScoped")
annotation("io.quarkus.test.junit.QuarkusTest")
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_16.toString()
kotlinOptions.javaParameters = trwue
kotlinOptions.freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
}
Output of uname -a
or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version
or gradlew --version
)
No response
Additional information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
RESTEasy: Could not find writer for content-type application ...
The single param for this service is an annotated java object. I am using org.jboss.resteasy.client.ClientRequest to send the request to the service. However,...
Read more >How to solve could not find writer for content-type application ...
ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type: A common cause of this issue is that ...
Read more >javax.ws.rs.ProcessingException: RESTEASY003215 ... - GitHub
rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type: java.lang.Strin #172.
Read more >Could not find writer for content-type ... - Google Groups
ProcessingException : RESTEASY003215: could not find writer for content-type application/xml type: javax.ws.rs.client.Entity. What am i missing?
Read more >RESTEASY003215| JBoss.org Content Archive (Read Only)
... task-1) Caused by: javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type text/plain type: java.lang.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Glad to hear it.
Yeah, I was thinking of the same thing. I’ll open a draft and see it how it goes
Oh man, big no-no crossing the streams like that 🙈 I thought it was pulling in generic
mutiny
operators for either of therest-client
/rest-client-reactive
implementations.Whoops.
Let me remove and test again, thank you for that piece of info 🤦 🙏