trunjob not seeing context

Six Stars

trunjob not seeing context

In order to test the passing of parameters to a subjob, I have create a small job just to focus on the use of context variables. But I cannot get it working. The subjob does not 'see' the context variable. I hope you can tell me what I am doing wrong.

 

  • I have create a context in which the variable _infile_ is set
  •  I have created a subjob which explicitly sets this variable in the context
  • I have created a tRunjob that is triggered by the subjob OK event on that subjob as well as a tMsgBox that triggers on the subjob OK event which displays "infile is " + context.infile
  • in the tRunJob I have ticked 'transmit whole context'
  • the subjob that is used by tRunjob does a simple csv to xml conversion. Its first component is a tFileInputDelimited in which the file name input is filled with context.infile.

 

When I run this, the msgbox correctly displays the value of the infile context variable, but on the console an error message is display which says it cannot find the variable (see below). I hope you can explain this.

I am using open studio 7.0.1

 

thanks in advance, Ruud

 

ContextLoad_1 set key "infile" with value "/home/ruud/overz/TOS_DI-20180411_1414-V7.0.1/workspace/PROBEER/uitzoek/werknemers.csv"
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
infile cannot be resolved or is not a field
infile cannot be resolved or is not a field
infile cannot be resolved or is not a field

at probeer.converteer_werknemers_0_1.converteer_werknemers.tFileInputDelimited_1Process(converteer_werknemers.java:899)
at probeer.converteer_werknemers_0_1.converteer_werknemers.runJobInTOS(converteer_werknemers.java:1896)
at probeer.converteer_werknemers_0_1.converteer_werknemers.runJob(converteer_werknemers.java:1759)
at probeer.use_job_0_1.use_job.tRunJob_1Process(use_job.java:1174)
at probeer.use_job_0_1.use_job.tFixedFlowInput_1Process(use_job.java:853)
at probeer.use_job_0_1.use_job.runJobInTOS(use_job.java:1471)
at probeer.use_job_0_1.use_job.main(use_job.java:1310)
[statistics] disconnected

 


Accepted Solutions
Sixteen Stars

Re: trunjob not seeing context

Can you show your tFileOutputXML config please? I notice that the tContextLoad does not appear to be loading a value for "dir". Of course, this could just be that the error is thrown before this value is reported to have been set, but I would look at this.


All Replies
Sixteen Stars

Re: trunjob not seeing context

It would be easier to figure this out if you put some screenshots up of tRunJob config, your parent job context variables and your child job context variables. However, I suspect that you have not created the context variable in your child job (run by the tRunJob). Either that, or the context variable is not referenced correctly in your tMsgBox component.

Six Stars

Re: trunjob not seeing context

However, I suspect that you have not created the context variable in your child job (run by the tRunJob). Either that, or the context variable is not referenced correctly in your tMsgBox component.

 

That could be well the case. What exactly do you mean by 'you have not created the context variable in your child job'?

The tMsgBox is not the problem, by the way, it is the job that is run by the tRunJob that causes the problem. The tMsgBox is there to show the variable is set, which is the case. But since I do not understand your remark about the child job, that must be the blank spot in my understanding.

Can you explain about this?

 

Ruud

Sixteen Stars

Re: trunjob not seeing context

If you want to pass the value of a context variable from a parent job (the job with the tRunJob in it) to a child job (the job called by the tRunJob) using "Transmit whole context", both the parent and child job MUST have the context variable in their respective "Contexts" tabs. A context variable only exists within the life span of a job. If you want to pass the value between nested jobs you need to make sure that all jobs that require it, have it created.

Six Stars

Re: trunjob not seeing context

hello rhall,

 

I have tried as you suggested, in fact I did so already. But it has not the desired effect. The context variable does not seem to be passed. The strange thing is the output of the run job is changed somewhat (at first, it said the field cannot be found, now the value is not used). I have attached screenshots. I have used 'Transmit whole context" in the tRunJob.

In the tFileInputDelimited component in the file field the values context.infile is filled in. But it results in a nullPOinterException.

Hopefully, the screenshots provide enough information for you to see the problem in this test job.

The shown messagebox is the result of the tMsgBox, which is executed BEFORE the tRunJob and shows that the infile context variable is known and filled with a value.

If more information is needed, please let me know...

 

Thanks, Ruud

Sixteen Stars

Re: trunjob not seeing context

Can you show your tFileOutputXML config please? I notice that the tContextLoad does not appear to be loading a value for "dir". Of course, this could just be that the error is thrown before this value is reported to have been set, but I would look at this.

Six Stars

Re: trunjob not seeing context

Yes! Your remark put me on the right track. I cannot believe I have overlooked that is was now the tFileOUtputXML component that caused the error message. I was so used to the idea the problem was the TFileInputDelimited component that I did not read the message properly.

In that component, I used a global parameter, the remnant of an earlier test (which is not working anyway between parent and child jobs). I changed that and now the job runs as expected.

 

Thank you very much for your patience with me. Ruud

Sixteen Stars

Re: trunjob not seeing context

No problem. Glad you got it sorted. It really helps to look at the Java error stack you get and look for the line of code that caused the error. From this, you can take a look at the line of code (the code tab) and from that you can identify either the error, or at least the component that is causing it.