8

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.

Ashfaq Khan
  • 101
  • 1
  • 4

4 Answers4

4

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'
            }
        }
    }
Infeligo
  • 11,715
  • 8
  • 38
  • 50
2

For me it worked to add the following JVM Option:

--add-opens java.base/java.lang.invoke=ALL-UNNAMED
michaeak
  • 1,548
  • 1
  • 12
  • 23
0

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
0

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

borino
  • 1,720
  • 1
  • 16
  • 24