Hello team,
Yasson version used is 1.03.
Below exception is seen when REST service is sending a response :
---------------------------
Caused By: java.lang.IllegalAccessException: class org.eclipse.yasson.internal.model.GetFromGetter cannot access class sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl (in module java.base) because module java.base does not export sun.reflect.annotation to unnamed module @6c0d7c83
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
at java.base/java.lang.reflect.Method.invoke(Method.java:560)
at org.eclipse.yasson.internal.model.GetFromGetter.internalGetValue(GetFromGetter.java:28)
-----------------------------
I tried adding below in module-info.java file and adding the compiled class in the root of the JAR containing the JAXB related model classes. But, this did not work.
module mycompanyrest {
opens mycompany.rest.model.policy;
exports mycompany.rest.model.policy;
}
After adding JVM options --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED & --add-exports java.base/sun.reflect.annotation=ALL-UNNAMED
error message changed to
------------------------
Caused By: java.lang.IllegalAccessException: class org.eclipse.yasson.internal.model.GetFromGetter cannot access a member of class sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl (in module java.base) with modifiers "public"
------------------
Thank you for your help in advance.
Regards,
Abhijit