Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Custom Extension JAR Job: java.lang.ClassNotFoundException

Roro
New Contributor III
New Contributor III

Hello,

I have been trying to run a custom jar job but, every time I run the job I get the class not found exception. I have searched the forum for an answer and followed all the required steps when uploading the custom jar file into our environment. Nothing has worked so I would require some assistance.

I have followed this post:https://forums.saviynt.com/t5/identity-governance/how-to-build-develop-custom-java-jar-solution/m-p/... and quite a few more for information with no help.

  • Jar is compiled with java 1.8
    • I can run the jar file on my laptop
  • server has been restarted multiple times for UI
  • I have made sure to add the correct config in the job

 

26 REPLIES 26

NM
Honored Contributor III
Honored Contributor III

Hi @Roro , JDK version 8?

Plus create a support ticket to restart the server.


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

Roro
New Contributor III
New Contributor III

Yes JDK version 8 and I will create a ticket to restart server.

Do we need to always raise a ticket for the restart when we change edit the code or is this more of a one time thing?

NM
Honored Contributor III
Honored Contributor III

@Roro ideally you don't have to but sometimes what I have seen UI restart doesn't load the system properly .. so..

Btw what is the use case to use jar?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

NM
Honored Contributor III
Honored Contributor III

@Roro , got it ..

If you find the above answer helpful please accept as solution and hit kudos button.


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

rushikeshvartak
All-Star
All-Star
  • Delete Jar file all versions
  • Reupload Jar
  • Restart.
  • Validate Jar job details such as class name/method name

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Roro
New Contributor III
New Contributor III

Done all of the steps multiple times with no help unfortunately.

I created a ticket based on what @NM said and we are now waiting for the ticket to be handled. Hopefully this will sort it out.

First time jar invoke needs restart so saviynt restart will help


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Roro
New Contributor III
New Contributor III

So after the restart the code is still not executing. I will add screenshots to better get an idea where I am at.

I even used the zipExtractor found at the bottom of this forum post: https://forums.saviynt.com/t5/identity-governance/how-to-send-csv-file-instead-of-zip-using-sftp-con...

Would really appreciate more help on this.

execute method needs parameters; did you send the same as arguments?

  • I will suggest write own jar for secure authentication 

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

NM
Honored Contributor III
Honored Contributor III

@Roro method expects arguments .. you need to pass arguments in the job.


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

Roro
New Contributor III
New Contributor III

Alright just to get me started here what would it be in this case? Also what is the reason for the logs to be giving me an error of class not found if the issue would be that I am not providing arguments. I did already add an empty json (says to add the arguments in json) to at least verify that the class is found. 

Is there really no good documentation on how this can be done so everyone trying to create a custom jar would not have to post into the forum and ask the same questions?

  1. Share your java code screenshot.

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Roro
New Contributor III
New Contributor III

Roro_0-1724160018804.png

Here is the code (exact copy the one in the other post) just want to get something running then I could actually code my own stuff in. Btw now that I am asking can I just have a main method that would not expect any arguments? I have tried that also but still nothing is running.

 

  • Try simple hello world jar 

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Roro
New Contributor III
New Contributor III

I have now tested with a simple hello world jar and I still have issues with getting anything to run

  • first off I tested a method with no arguments expected got the same error
  • second I tested a few different cases with only one line as the logger.
    • I added pictures of these cases for this.

Could I please get an example jar that should work and also the code that is in it. Also what the package, method and arguments I should add into our job to verify that the issue is on my side and not the code or something else.

I appreciate the help a lot!

Roro
New Contributor III
New Contributor III

Forgot to add that this is the full error for test case 3

{"code":"invocationError","message":"error invoking the extension","details":"com.fasterxml.jackson.databind.exc.MismatchedInputException Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)\n at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 71] (through reference chain: com.saviynt.extension.model.SavExtension[\"args\"]->java.util.LinkedHashMap[\"args\"])"}

Note : please attach images in inline nettime; its hard to check each image manually

Please share below

  • Jar code 
  • logs in text format
  • Also if main does not needs arguments keep arguments field blank

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Roro
New Contributor III
New Contributor III

So I got this working by using Invoke Extension JAR Job (ExternalJarJob) **DEPRECATED** Use CustomExtensionsJob instead  which makes no sense to me but I guess this is just Saviynt being Saviynt (get used to it).

For anyone else having similar issues as I did the solution is (for now)

  1. Use Invoke Extension JAR Job (ExternalJarJob)
    • this should get fixed by Saviynt hope sooner rather than later.
  2. Make sure to build with java 8 (openjdk works I used openjdk version "1.8.0_422-internal")
  3. Our job had these as the values for triggering.
    • FULL_CLASS_NAME_WITH_PACKAGE
    • METHOD_NAME
    • ARGUMENTS
  4. Restarting the service works from the UI maybe for the first time you add the file ask for Saviynt to restart.

I will paste the java code bellow for anyone interested. FYI the system out prints don't work on Saviynt only used for local testing.

 

 

package com.custom.utilities;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class ZipExtractor {
public static void main(String[] args) {
Map<String,String> data = new HashMap<String,String>();
data.put("path", "ONLY TO TEST LOCALLY");
data.put("fileName", "ONLY TO TEST LOCALLY");
ExtractCSV(data);
}

public static File getLastModified(String directoryFilePath) {
File directory = new File(directoryFilePath);
File[] files = directory.listFiles(File::isFile);
long lastModifiedTime = Long.MIN_VALUE;
File chosenFile = null;

if (files != null) {
for (File file : files) {
if (file.lastModified() > lastModifiedTime && file.getName().toString().contains(".zip")) {
chosenFile = file;
lastModifiedTime = file.lastModified();
}
}
}

return chosenFile;
}

public static void ExtractCSV(Map<String,String> args) {
String zipDirectoryPath = args.get("path");
System.out.println(zipDirectoryPath);
String zipFileName = "";
String csvFileName = args.get("fileName");
try {
try {

zipFileName = getLastModified(zipDirectoryPath).getName().toString();

} catch (Exception e) {
e.printStackTrace();
}

ZipFile zipFile = new ZipFile(zipDirectoryPath+zipFileName);
ZipEntry entry = zipFile.getEntry(zipFileName.replace(".zip", ".csv"));

if (entry != null) {
InputStream inputStream = zipFile.getInputStream(entry);
FileOutputStream outputStream = new FileOutputStream(new File(zipDirectoryPath + csvFileName));

byte[] buffer = new byte[1024];
int length;

while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}

outputStream.close();
inputStream.close();
zipFile.close();

System.out.println("CSV file extracted successfully.");
} else {
System.out.println("CSV file not found in the ZIP archive.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

@Roro  thanks for confirmation .

Am not able find, CustomExtensionsJob  and in job need to pass any arguments ? provide the screenshot for job variable reference. ?

you mean  sysout it wont work and display , need to use log4j for printing values?

 


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

Roro
New Contributor III
New Contributor III

Hey so the CustomExtensionsJob is found at least for us when searching for JAR when creating a new job picture bellow:

Screenshot 2024-08-23 at 21.01.33.png

 And what it is asking is the same things as the Invoke Extension JAR Job (ExternalJarJob) picture bellow:

Screenshot 2024-08-23 at 21.02.08.png

 For the logs I know they don't work in Saviynt, I was just lazy and did not remove them after I did some testing locally.

NM
Honored Contributor III
Honored Contributor III

Hi @Roro , you are executing directly extractcsv method right from invoke job?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

NM
Honored Contributor III
Honored Contributor III

Hi @Roro , where are you storing the extracted csv file under data files section?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

NM
Honored Contributor III
Honored Contributor III

@Roro did you do restart after each and every jar upload?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

Roro
New Contributor III
New Contributor III

@NM  I would like to point out I got this problem solved I just wanted someone from Saviynt to come and comment on why a deprecated job works but the one that should does not. Thanks for the advice!

adarshk
Saviynt Employee
Saviynt Employee

CustomExtensionsJob  is currently not released and will be available in future. from 24.5.x onwards this has been removed from the Job. 

For time being, you can continue using Invoke Extension JAR Job (ExternalJarJob) which is will work to invoke JARs  and the update on CustomExtensionsJob  will be announced in the upcoming release notes. 

Thanks