Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[yasson-dev] IllegalAccessException with JDK 17 + Jersey 2.40

Hello team,

I came across [yasson-dev] Issue with yasson jar in jaxrs-ri-2.27. (eclipse.org). But, we are using Jersey 2.40 with JDK 17.

Below exception is seen with 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

Back to the top