and more in a single search tool across platforms. Read the announcement here. |
12/04/2023 06:57 AM
Hi,
I am working on a custom JAR file. The JAR file will be executed via a job of type = "Invoke Extension JAR Job (ExternalJarJob)". The method being called from the job is returning the status of the execution in the following manner:
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", message);
jsonObject.put("description", description);
return jsonObject.toString();
If the execution is successful, message="Success", else message="Failure". However, even when message is set to "Failure", the job status in Saviynt is Success. How do we configure the JAR such that when execution is unsuccessful, job status should be "Failure"?
Thanks,
Kunal
Solved! Go to Solution.
12/04/2023 07:27 AM
You can't control job status from Jar. Jar job call respective class
12/06/2023 01:35 AM
Hi @rushikeshvartak , Thanks for replying.
Can you please let me know what is the usage of returning the following from the JAR:
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", message);
jsonObject.put("description", description);
return jsonObject.toString();
12/06/2023 07:56 PM
As per documentation message should reflect on job status page
The 'message' attribute indicates 'Success or Failure' response for the operation. The 'data' indicates the values to be returned for example account values.
01/22/2024 12:43 AM
I have observed that you can mark the status as "Failure" for a ExternalJarJob by throwing an exception from your custom JAR, that you are invoking via this job.
Therefore, you can create a custom Exception class as part of your JAR. Handle the scenarios in your JAR where you want the job to fail and throw your custom exception. This would mark the job status as Failure.
Thanks,
Kunal
01/22/2024 10:16 PM
can you share sample code
01/23/2024 04:57 AM
Hi @rushikeshvartak ,
Please find below the sample code:
Create a Custom Exception class:
package com.myjar.exceptions;
public class CustomException extends Exception {
private static final long serialVersionUID = 1L;
public CustomException(String errorMessage) {
super(errorMessage);
}
}
Then, in your code, wherever you want to handle a failure scenario, throw your custom exception:
throw new CustomException("handling a failure scenario");
The method you call from the ExternalJarJob should eventually throw your custom exception. This would mark the job status as Failure.