Reputation: 111
I have a Spring Feign client which is sending POJO object to remote endpoint using POST and my application start-up fails with below exceptions.
java.lang.reflect.InaccessibleObjectException: Unable to make field static final java.lang.invoke.MethodHandles$Lookup java.lang.invoke.MethodHandles$Lookup.IMPL_LOOKUP accessible: module java.base does not "opens java.lang.invoke" to unnamed module @420a85c4
Below the dependencies I am using in my application.
java version: 17
spring boot version: 2.5.3
spring boot cloud version: 2020.0.3
spring boot starter openfeign version: 2.2.8.RELEASE
As recommended in https://github.com/OpenFeign/feign/issues/935, I had tried
workaround solution: Adding this jvm option '--add-opens java.base/java.lang.invoke=ALL-
UNNAMED' worked.
Any other alternative suggestion other than jvm argument are most welcome.
Upvotes: 9
Views: 10546
Reputation: 1750
I have same error when i declare default method (method with implementation) in interface class marked with @FeignClient
. I just remove default method and the error has disappeared
Upvotes: 0
Reputation: 1
For JDK 9+, if you use the JVM options to fix the problem, add another =
into the JVM options:
e.g.
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
Upvotes: 0
Reputation: 11811
Force OpenFeign version to at least 11.7, which has this issue solved.
If you are using Spring Dependency Management plugin, then you can do it like this (Gradle example):
dependencyManagement {
dependencies {
dependencySet(group: 'io.github.openfeign', version: '11.7') {
entry 'feign-core'
entry 'feign-jackson'
entry 'feign-slf4j'
entry 'feign-soap'
entry 'feign-jaxb'
}
}
}
Upvotes: 4
Reputation: 1679
For me it worked to add the following JVM Option:
--add-opens java.base/java.lang.invoke=ALL-UNNAMED
Upvotes: 5