Hello, We are trying to upgrade PDI CE 7.0 to PDI CE 9.3, most of the steps (wrapper job/ktr) are working, but the step where er have used User defined Java class is not running (giving error):
Logs:
2023/11/09 08:50:31 - Mask MSISDN.0 - distribution activated
2023/11/09 08:50:31 - Mask MSISDN.0 - Starting allocation of buffers & new threads...
2023/11/09 08:50:31 - Mask MSISDN.0 - Step info: nrinput=1 nroutput=1
2023/11/09 08:50:31 - Mask MSISDN.0 - !BaseStep.Log.GotPreviousStep!
2023/11/09 08:50:31 - Mask MSISDN.0 - input rel is 1:1
2023/11/09 08:50:31 - Mask MSISDN.0 - Found input rowset [Read data to synchronize.0 - Mask MSISDN.0]
2023/11/09 08:50:31 - Mask MSISDN.0 - output rel. is 1:1
2023/11/09 08:50:31 - Mask MSISDN.0 - Found output rowset [Mask MSISDN.0 - Select values.0]
2023/11/09 08:50:31 - Mask MSISDN.0 - Finished dispatching
2023/11/09 08:50:31 - Mask MSISDN.0 - ERROR (version 9.4.0.0-343, build 0.0 from 2022-11-08 07.50.27 by buildguy) : Error initializing UserDefinedJavaClass:
2023/11/09 08:50:31 - Mask MSISDN.0 - ERROR (version 9.4.0.0-343, build 0.0 from 2022-11-08 07.50.27 by buildguy) : org.pentaho.di.core.exception.KettleException:
2023/11/09 08:50:31 - Mask MSISDN.0 - null
Code in UDJC (Mask MSISDN
):
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.codec.binary.Hex;
MessageDigest mdSha256;
String salt = "<some_salt>";
public boolean init(StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface)
{
if ( !parent.initImpl(stepMetaInterface, stepDataInterface) ) {
return false;
}
try {
mdSha256 = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
return false;
}
return true;
}
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
if (first){
first = false;
}
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
r = createOutputRow(r, data.outputRowMeta.size());
String msisdn = get(Fields.In, "msisdn").getString(r);
String masked_msisdn = null;
if (msisdn != null) {
mdSha256.reset();
mdSha256.update((salt + msisdn).getBytes());
masked_msisdn = String.valueOf( Hex.encodeHex( (byte[]) mdSha256.digest() ) );
}
// Set a value in a new output field
get(Fields.Out, "masked_msisdn").setValue(r, masked_msisdn);
Same KTR/Step works in PDI v8.3.