I’m doing REST API call via a rule using the below code for it:
import java.io.OutputStream;
import java.util.List;
import java.io.*;
import org.json.JSONArray;
import org.json.JSONObject;
HashMap map = new HashMap();
public void AllVault () {
String endpointURL = "https://apipam.dsb.dk/cspm/ext/rest/vaults?limit=0";
log.error("End Point URL" +endpointURL);
URL url = new URL(endpointURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type", "application/json");
String auth = "*********" + ":" + "******";
byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes());
String authHeaderValue = "Basic " + new String(encodedAuth);
conn.setRequestProperty("Authorization", authHeaderValue);
int responseCode = conn.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// log.error(response.toString());
JSONObject responseJson = new JSONObject(response.toString());
JSONArray vaultsArray = responseJson.getJSONArray("data");
for (int i = 0; i < vaultsArray.length(); i++) {
JSONObject vault = vaultsArray.getJSONObject(i);
map.put(vault.getString("name"),vault.getInt("id"));
//log.error("|" +vault.getString("name") +"| " + vault.getInt("id"));
}
}
I noticed this error after upgrading from Java OpenJDK 11 to Java OpenJDK 17. The same rule worked fine with Java OpenJDK 11. Any suggestions for resolving this error would be helpful. Thanks in advance.
Please share any images or screenshots, if relevant.
[Please insert images here, otherwise delete this section]
Please share any other relevant files that may be required (for example, logs).
[Please insert files here, otherwise delete this section]
Share all details about your problem, including any error messages you may have received.
[Replace this text with the problem that you are facing]
The error you’re encountering is due to changes in Java module access controls introduced in Java 9 and later versions. Java 17 enforces stricter encapsulation, and HttpsURLConnectionImpl is part of a package that is not exported to unnamed modules, which includes BeanShell.
To resolve this issue, you can try adding the --add-exports option to allow reflective access to the required module. This needs to be configured in the JVM arguments for the Tomcat server where IdentityIQ is running.
You can add the following argument to your Tomcat startup script:
This will export the package to all unnamed modules, which should resolve the IllegalAccessException. If you are using catalina.sh or catalina.bat, modify the CATALINA_OPTS or JAVA_OPTS environment variable to include this option.
For example, you might add it like this in catalina.sh: