Hi, got an issue that I can’t figure out. I made a...
# http4k
r
Hi, got an issue that I can’t figure out. I made a lib based on http4k that exposes a method that calls a url using OkHttp client. When I use it from a http4k client app I have no problem, but I also tried to use it from a SpringBoot (kotlin) project and I get this error:
Copy code
Companion
java.lang.NoSuchFieldError: Companion
	at org.http4k.client.OkHttpKt.requestBody(OkHttp.kt:75)
	at org.http4k.client.OkHttpKt.asOkHttp(OkHttp.kt:68)
	at org.http4k.client.OkHttpKt.access$asOkHttp(OkHttp.kt:1)
	at org.http4k.client.OkHttp$invoke$1.invoke(OkHttp.kt:38)
	at org.http4k.client.OkHttp$invoke$1.invoke(OkHttp.kt:35)
It’s the basic client, nothing fancy
OkHtttp()
if I replace that with JavaHttpClient() or ApacheClient() all works. Does that ring a bel or should try to make test projects to show it ? The error line is the if line in this function
Copy code
private fun Request.requestBody() =
    if (permitsRequestBody(method.toString())) body.payload.array().toRequestBody()
    else null
So comparing the dependecies I see that in the Spring boot version the
http4k-client-okhttp
adds okhttp 3.14.9 instead of 4.9.1 in the http4k version.
d
Yep. Try to force the version maybe?
r
If in the lib i set the okhttp the dependency as:
Copy code
api("com.squareup.okhttp3:okhttp:4.9.1")
is not ok. If I do it in the SpringBoot app (as implement) is OK. but I shouldn’t have to care about that as in my spring boot app I’m not using okhttp in this client app…
Gradle dependency report does not help the only place where okhttp appears is in the http4k-client but yet the dependency is marked as omitted as (
(*) - dependencies omitted (listed previously)
) but there’s nowhere else…
Copy code
|    +--- org.http4k:http4k-client-okhttp:4.9.8.0
|    |    +--- org.http4k:http4k-core:4.9.8.0 (*)
|    |    +--- com.squareup.okhttp3:okhttp:4.9.1 -> 3.14.9
|    |    |    \--- com.squareup.okio:okio:1.17.2 -> 1.17.5
|    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.32 -> 1.5.10 (*)
|    \--- com.squareup.okhttp3:okhttp:4.9.1 -> 3.14.9 (*)
d
The problem is that the version of okhttp being used in the lower version was 3.x. 4.x was the kotlin rewrite
Have a look at when the Http4k version of okhttp went to v4 and pull in a verison before that manually?
r
Same thing happens when I just import add as dependency to the project
http4k-client-okhttp:4.9.8.0
well is the fu**ing Spring Boot Bom that screws it up… sorry for the bother… https://github.com/Azure/azure-sdk-for-java/issues/7233
thought the bom declares dependecies for only the modules you are realy useding not everything on the planet… on the other hand is a maven thing shouldn’t have expect to be smart.
651 Views