IBM / keyprotect-java-client

Java/JRE SDK for interacting with the IBM Cloud KeyProtect service.
https://ibm.github.io/keyprotect-java-client/
Apache License 2.0
1 stars 8 forks source link

Error: "module java.base does not "opens java.lang" to unnamed module" #29

Open chris-giblin opened 2 years ago

chris-giblin commented 2 years ago

Using the Key Protect Java SDK with Java 11 and Java 17, I am getting the error in the subject of the issue (stacktrace below). While there are JVM workarounds, which I cannot rely on, ultimately it is up to the framework, in this case the Key Protect SDK, to update its code. Could we get.a fix in the SDK for this?

FYI, Stackoverflow discussion: https://stackoverflow.com/questions/41265266/how-to-solve-inaccessibleobjectexception-unable-to-make-member-accessible-m

Stacktrace:

java.lang.RuntimeException: Error while fetching access token from token service: 
    at com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator.getToken(TokenRequestBasedAuthenticator.java:252)
    at com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator.authenticate(TokenRequestBasedAuthenticator.java:194)
    at com.ibm.cloud.sdk.core.service.BaseService.setAuthentication(BaseService.java:260)
    at com.ibm.cloud.sdk.core.service.BaseService.createCall(BaseService.java:198)
    at com.ibm.cloud.sdk.core.service.BaseService.createServiceCall(BaseService.java:236)
    at com.ibm.cloud.ibm_key_protect_api.v2.IbmKeyProtectApi.getKey(IbmKeyProtectApi.java:419)
    at io.strimzi.kafka.topicenc.kms.keyprotect.KeyProtectKms.getKey(KeyProtectKms.java:64)
    at io.strimzi.kafka.topicenc.kms.keyprotect.KeyProtectTest.basicTests(KeyProtectTest.java:70)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.lang.Throwable.detailMessage accessible: module java.base does not "opens java.lang" to unnamed module @cd8e913c
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
    at com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
    at com.google.gson.Gson.getAdapter(Gson.java:458)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
    at com.google.gson.Gson.getAdapter(Gson.java:458)
    at com.google.gson.Gson.fromJson(Gson.java:931)
    at com.ibm.cloud.sdk.core.util.ResponseUtils.getValue(ResponseUtils.java:149)
    at com.ibm.cloud.sdk.core.util.ResponseConverterUtils$6.convert(ResponseConverterUtils.java:137)
    at com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator$2.run(TokenRequestBasedAuthenticator.java:315)
    at java.base/java.lang.Thread.run(Thread.java:884)
Rishi-web commented 2 years ago

@chris-giblin may I know, like what operation you performed to hit this issue, little background what you tried and face this issue will be very helpful.

Rishi-web commented 2 years ago

Also the unit test what you are talking here - https://github.com/strimzi/topic-encryption/issues/53 is it w.r.t - https://github.com/IBM/keyprotect-java-client unit test-cases or something different.

Rishi-web commented 2 years ago

PR - https://github.com/IBM/keyprotect-java-client/pull/33

dinesh-venkatraman-g commented 2 years ago

@chris-giblin we have released a fix as part of 0.2.4. Can you verify with this release and confirm if it resolved?