'"java.lang.ExceptionInInitializerError" error in RestAssured post request with body

I'm using restassured library and at the below line i'm getting "java.lang.ExceptionInInitializerError" error caused by "Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make private java.lang.Class(java.lang.ClassLoader,java.lang.Class) accessible: module java.base does not "opens java.lang" to unnamed module @36f6e879" The baseURI is a http link and token_Body is alphanumeric string. I"m not sure what exactly is the issue. My java -version yields

"java version "18.0.1.1" 2022-04-22
Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)"

Code:

String bearerToken = given(). with().
              header("Content-Type", "application/x-www-form-urlencoded"). body(token_Body).
              when(). post(baseURI). then(). extract().asString();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source