Two Stars

Context map - general method failures



I am having an issue whilst trying to use the generic methods, context.get(), context.containsKey() and context.getOrDefault().

When trying to use these, although the context parameter is defined, the built-in methods are unable to locate/access the key.

Has anybody any suggestions to what I am doing wrong?


I have created a basic job, with one single Context param defined (RerunFlg - Boolean - true) to demonstrate the issue.

In the job I then do the following:


tContextDump -Row-> tLogRow

  | onSubJobOk



Code for tJava1:


// Context Param 'RerunFlg' defined as boolean 'true'


System.out.println( context.RerunFlg );                                    // true

System.out.println( context.containsKey("RerunFlg") );                     // false (expecting true)

System.out.println( context.get("RerunFlg") );                             // null (expecting true)

System.out.println( context.getOrDefault("RerunFlg", ((boolean) false)) ); // false  (expecting true)

String s= "RerunFlg";

System.out.println( context.containsKey(s) );                              // false (expecting true)

System.out.println( context.get(s) );                                      // null (expecting true)

System.out.println( context.getOrDefault(s, ((boolean) false)) );          // false (expecting true)



Job output:


Starting job testCtx at 13:14 06/02/2018.


[statistics] connecting to socket on port 4071

[statistics] connected


|  tLogRow_1   |


|key     |value|


|RerunFlg|true |










[statistics] disconnected

Job testCtx ended at 13:14 06/02/2018. [exit code=0]

Fifteen Stars

Re: Context map - general method failures

Take a look at your job's code (click on the code tab). You will see that the context object is actually an instance of the ContextProperties class which is a subclass of java.util.Properties and created during the design of your job. A copy of a typical example can be seen below....


// create application properties with default
	public class ContextProperties extends java.util.Properties {

		private static final long serialVersionUID = 1L;

		public ContextProperties(java.util.Properties properties) {

		public ContextProperties() {

		public void synchronizeContext() {

			if (new1 != null) {

				this.setProperty("new1", new1.toString());


			if (new2 != null) {

				this.setProperty("new2", new2.toString());


			if (new3 != null) {

				this.setProperty("new3", new3.toString());



		public String new1;

		public String getNew1() {
			return this.new1;

		public String new2;

		public String getNew2() {
			return this.new2;

		public String new3;

		public String getNew3() {
			return this.new3;

The reason your code is failing is to do with how the java.util.Properties class is written. The methods you are calling are methods of the Properties class' superclass HashTable. There is a brief explanation for the difference between "get" and "getProperty" (which you should try and will see it works) here:


Essentially,this is not a bug.


A question related to this, but why are doing this anyway? You should be able to interact with your context variables using context.variable_name. Do you have a requirement which makes this interaction with context variables not provide what you need? If so, maybe I can help with a workaround?

Rilhia Solutions
Four Stars

Re: Context map - general method failures

Hello, thanks for those explanations.

I'm in the same case than robery : I need to get dynamically a context variable.

Is there a way to do it ? context.get() / context.getProperty() doens't work, and I don't know enough of Java to find the good syntaxe throw class and superclass.