cancel
Showing results for 
Search instead for 
Did you mean: 

MandatoryFieldNullException while creating a job chain

nanda_kumar21
Active Contributor
0 Kudos

Hi Everyone,

Build version - M33.104.

I'm trying to create a job chain by using a For loop:


//JobA will be in step 1, job B in step 2 so on and always sequential, the array can contain any number of child jobs, and they will always be sequential

String [] str1 = {"ECC_JO_FI_OT_VIM_COLLECTION_AGGREGATION","descr","comment","jobA","jobB"}

int len = str1.length-3;

for (int i=1;i<=len;i++)

            {

                JobChainStep jcs1 = jc.createJobChainStep();

                jcs1.setSequenceNumber(new Long(i));

                jcsOut.println("Sequence number : "+jcs1.getSequenceNumber());

                String name = "Step "+i;

                jcs1.setName(name);

                JobChainCall jcc1 = jcs1.createJobChainCall();

                jcc1.setSequenceNumber(new Long(1));

                jcc1.setJobDefinition(jcsSession.getJobDefinitionByName(str1[i+2]));

            }

I get the following error:

JCS-122035: Unable to persist: JCS-MULTI: Modification vetoed: JCS-102074: Field Job Definition on Job 1 (<Job Definition Not Set>) in step Step 1 of Job Chain OTX.ECC_JO_FI_OT_VIM_COLLECTION_AGGREGATION must be specified


When i do a dry run (without persisting) everything is fine, and the output (println inserted to reflect the values of each variables) is exactly how i want it - so this confirms i am passing the correct values.


But when i try to persist, i get the above error and i'm not able to pin point the actual reason for the error.

If i run without the for loop, passing exact values it works, but not when run in a for loop. What am i doing wrong?


Please help me solve this.


Thanks

Nanda

Accepted Solutions (1)

Accepted Solutions (1)

h_carpenter
Active Contributor
0 Kudos

Hi Nanda,

The following call is null for Step 1, Job 1:

jcc1.setJobDefinition(jcsSession.getJobDefinitionByName(str1[i+2]));


Maybe JobA is not in the GLOBAL partition, to be 100% on the safe side, remove the persist and perform the following:


jcc1.setSequenceNumber(new Long(1));


jcsOut.println(str1[i+2]);

Partition partition = jcsSession.getPartitionByName("OTX");

JobDefinition jd = getJobDefinitionByName(partition, str1[i+2]);

if (jd != null)

{

jcsOut.println("found");

}


jcc1.setJobDefinition(jcsSession.getJobDefinitionByName(str1[i+2])); 



Regards,


HP

nanda_kumar21
Active Contributor
0 Kudos

thanks a lot HP!

I lost about 5 hours in debugging this, and went in a completely different direction because i thought the jcs1 was getting initialized for every iteration and some how creating an generic List would help (which is not supported by Java 1.4 BTW, then  i was trying to use Arraylist) and thats when i saw your answer!

Please keep up the good work!

Thanks

Nanda

h_carpenter
Active Contributor
0 Kudos

Hi Nanda,

Thanks, you should really add null checks that print messages, that way you get a better understanding of what is wrong ...

In fact, my answer is not that good, because I forgot to replace jcsSession.getJobDefinitionByName(str1[i+2]) in the setJobDefinition.

Besides, something like this would help:

jcc1.setSequenceNumber(new Long(1));


jcsOut.println(str1[i+2]);

Partition partition = jcsSession.getPartitionByName("OTX");

JobDefinition jd = getJobDefinitionByName(partition, str1[i+2]);


if (jd != null)

{

jcsOut.println("found");

jcc1.setJobDefinition(jd); 

}

else

{

  if(partition != null)

  {

    jcsOut.println("jd "+str1[i+2]+" not found in partition "+partition.getName());

  }

  else

  {

    jcsOut.println("partition not found");

  }

throw new RuntimeException("job definition or partition not found, see messages above");

}

Regards,

HP

Answers (0)