View Only

 KTR's from PDI v7.0 not working in v9.3 - User defined java class step

Abhishek Sawant's profile image
Abhishek Sawant posted 11-21-2023 05:50

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):


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, 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, 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 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) {
      return false;
    r = createOutputRow(r, data.outputRowMeta.size());
    String msisdn               = get(Fields.In, "msisdn").getString(r);
    String masked_msisdn = null;
    if (msisdn != null) {
        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.

's profile image

Hi @Abhishek Sawant, I was able to create a simple KTR using the above code and it worked in both 7.0 and 9.4.

In your log, the only possible error is the message `null`. Are you able to attach the full KTR and log output to provide more information to help identify the issue?

Abhishek Sawant's profile image
Abhishek Sawant

Attaching full KTR, log output and system info.

Stephen Donovan's profile image
Stephen Donovan

I was thinking Java 8 vs 11, base libraries, imports etc.  But Mike's test clears some of those concerns.

One simple "test" is to do exactly what Mike did and drag a new UDJC step paste the code and attach it to the pipeline.  The "null" message may point to an XML element missing from the version 7 port.

Abhishek Sawant's profile image
Abhishek Sawant

Thank you, I've tried again with just table input ("select 1;") and UDJC and it worked.

Then I tried adding other steps and identified that, the Variables from Job (wrapper job) is not passed in transformation.

UDJC error was misleading, attached (word doc) is the actual issue - where the parameter is not getting passed, but same setup (ETL) works on Pentaho v7

Abhishek Sawant's profile image
Abhishek Sawant

Attaching Screenshot and snippet of logs (updated)