Talend GlobalMap variable Error, NullPointerException to count my inputrow NB_LINE - exception

I need to count how many inputs I have before starting the component tDenormalizeSortedRow (if I put a wrong number of line, the last values are lost).
The problem is that I used a global variable:
((Integer)globalMap.get("tConvertType_1_NB_LINE"))
But it throws an error:
Exception in component tJava_1 (TestIDuniqueextract)
java.lang.NullPointerException
I don't know why the global variable is null:

The global variable return NULL value if you use it in the same flow. So i need to send value to the next subjob with thashoutput/input and then use the global variable
refer to this link :
(https://community.talend.com/s/question/0D53p00007wWjJWCA0/globalmap-variable-error-javalangnullpointerexception)
Regards

Related

Reference : TypeError: Cannot read property [property name here] from undefined

Derived from Canonical question for TypeError Cannot [call method / read property / set property] of null in Google Apps Script
Proposed reference for questions like :
Why the Execution order of GS files in a Project causes TypeError: Cannot read property "sayName" from undefined.?
Testing a trigger causes ReferenceError: 'e' is not defined. or TypeError: Cannot read property *...* from undefined
TypeError: Cannot read property "0" from undefined
Google Script send form values by email, error: cannot read property "namedValues"
Not enough details from the OP but three different answers that for different scenarios
TypeError: Cannot call method "getName" of undefined
TypeError: Cannot read property 'value' of undefined (line 3, file "Code"). I have a trigger for on form submit and yet it still has an errorMissing character in property name (OP used value instead of values)
Description
The error message indicates that you are trying to access a property on an Object instance, but during runtime the value actually held by a variable is a special data type undefined.
See key terms definition at the bottom.
Causes:
The error occurs when accessing properties of an object, which does not exist.
If a property doesn't exist in a object, accessing that property results in undefined and eventually a type error, if undefined is accessed like a real object.. This maybe due to typos or using case insensitive names to access a property. A variation of this error with a numeric value in place of property name indicates that an instance of Array was expected. As arrays in JavaScript are objects, everything mentioned here is true about them as well.
const obj = {a:1};
const b = obj.b;//undefined because b isn't available on obj. But doesn't throw a error
console.log(b.toString())//Throws type error
Accessing Arrays index greater than the last element's index
Array.prototype.length returns the number of elements of the Array. This number is always greater than the last element's index, as JavaScript uses 0 based indices. Accessing any index greater than or equal to the length of the array results in this type error. Eg, when accessing 3rd element in a array of length 3,
const a = [[1],[2],[3]];
const getElement3 = a[3];//undefined,because `3`'s index is ``2`` not `3`;But doesn't throw a error
console.log(getElement3[0])//Throws type error
Accessing Event objects without a event:
There is a special case of dynamically constructed objects such as event objects that are only available in specific contexts like making an HTTP request to the app or invoking a function via time or event-based trigger.
The error is a TypeError because an "object" is expected, but "undefined" is received
How to fix
Using default values
Nullish Coalescing operator ?? operator in JavaScript evaluates the right-hand side if the left-hand is null or undefined. An expression like (myVar ?? {}).myProp (or (myVar ?? [])[index] for arrays) will guarantee that no error is thrown, if the property is at least undefined.
One can also provide default values: (myVar ?? { myProp : 2 }) guarantees accessing myProp to return 2 by default. Same goes for arrays: (myVar ?? [1,2,3]).
Checking for type
Especially true for the special case, typeof operator combined with an if statement and a comparison operator will either allow a function to run outside of its designated context (i.e. for debugging purposes) or introduce branching logic depending on whether the object is present or not.
One can control how strict the check should be:
lax ("not undefined"): if(typeof myVar !== "undefined") { //do something; }
strict ("proper objects only"): if(typeof myVar === "object" && myVar) { //do stuff }
Key Terms
Object
It's one of the JavaScript data types.
undefined
It's one of the JavaScript primitive data types.
To learn about the very basics of JavaScript data types and objects see What are JavaScript Data Types? and What exactly is an object? [JavaScript].
Original revision extracted from here (Credit to #OlegValter)

Octave - accessing aray elements from within a function

I want to populate an empty array, and then access individual elements from within a function.
a = [];
for i=1:10
a(i)=i;
end
function display_a(k)
a = a(k);
disp(a);
end
display_a(5)
Here I receive an error:
'a' undefined near line 8, column 7
Which means that a=a(k) within the function is not recognized as my array a. Any idea on how to pull this off?
I tried declaring a as a global variable. Apart from my understanding that declaring global variables is not a good practice, my function returns the whole array instead of just one, specified element.
Thank you in advance.

How can I find out if a SAP MII transaction provides an output property of a given name?

In a SAP MII transaction, I use a Dynamic Transaction Call to call a subtransaction. I would like to check if this transaction provides an output parameter of a given name. (Not if its value exists but if the property itself is available.)
Is there any way to do this apart from blindly linking to the expected property, defining ThrowOnLinkError = true and catching a possible exception?
Sure you can: use Catch blocks and then add Assignment block where you assing local variable: ThrowOnLinkError = true or log it by adding a Tracer block depending on how you want to receive the error.

MXNet initialization error on label variable

When I call module.fit() I'm getting an error
ValueError: Unknown initialization pattern for labelidx.
The symbol "labelidx" is the name I'm using for my label data -- I didn't want to use softmax_label because I'm not using softmax output, but that seems to be the default for a lot of thigns. It seems to be trying to initialize labelidx as a parameter, which is a mistake. How can I tell it this is an input not a learned parameter?
I figured this out.
When constructing the Module object, you need to tell it the names of the data (data_names) and labels (label_names). Each of these should be a list of string names. By default data_names=('data',), label_names=('softmax_label',), Otherwise it assumes everything else is learned parameters and will try to initialize them, leading to this error. Docs: http://mxnet.io/api/python/module.html#mxnet.module.module.Module
So in my case it needs Module(label_names=('labelidx',), ...)

'Unable to invoke CFC - The data for must be no more than 100 characters in length

I'm trying to call a method as follows:
<cfinvoke component="#variables.target#"
method="#arguments.methodName#"
argumentcollection="#arguments.args#"
returnvariable="rtn">
</cfinvoke>
However, I am getting the following error:
Unable to invoke CFC - The data for 'param_value' must be no more than
100 characters in length.' faultDetail:''
The variable arguments.args is a struct and one of its elements looks like this:
{
param_name: 'property_uid',
param_value : '00000000-0000-0000-0000-0000000213131200,00002131300-0000-0000-0000-000000000000,00000000-0000-0000-0000-0000000002122,00000000-0000-0000-0000-000000032242
}
I know the problem is caused by this element, but don't know how to fix it.
Note that I've already updated the Maximum number of POST request parameters from 100 to 300 in the CF Administrator.
The variable property_uid is currently a list and the list's value is too long to be passed in as a struct key's value. Use listToArray() to send the data as an array. Inside the function, convert it back using arrayToList() if you need the data as a list again.
Please check the code of the invoked function (the function name can be found in your variable arguments.methodName in the component of variables.target).
Look for the tag <cfparam name="param_value" ...> and check if there is a maxlength attribute defined. It's probably set to 100 and thus causes ColdFusion to throw an exception if you pass more than 100 characters to said parameter.
Having a limit of 100 characters is probably a design descision on your side (database scheme?), so you need to figure this out by yourself.