[resolved] NullPointerException globalVar

One Star

[resolved] NullPointerException globalVar

I have a job with two loop and i cannot use a globalVar throught my job, after the first iteration the job failed.
connecting to socket on port 3611
connected
Exception in component tJava_3
java.lang.NullPointerException
at datawarehouse.testerror_0_1.testERROR.tLoop_4Process(testERROR.java:852)
at datawarehouse.testerror_0_1.testERROR.tJava_4Process(testERROR.java:650)
at datawarehouse.testerror_0_1.testERROR.runJobInTOS(testERROR.java:3911)
at datawarehouse.testerror_0_1.testERROR.main(testERROR.java:3758)
disconnected
See print screen for a description

Accepted Solutions
Community Manager

Re: [resolved] NullPointerException globalVar

Hi
context.getProperty("current_year").equals(
String.valueOf((Integer) globalMap
.get("tLoop_4_CURRENT_VALUE")))

The problem is caused by this code, it returns a null value, modify it to the below code will work, because you use a global var to store the value on tJava_4.
((String)globalMap.get("current_year")).equals(
String.valueOf((Integer) globalMap
.get("tLoop_4_CURRENT_VALUE")))
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] NullPointerException globalVar

Hi
Can you show us the Java code of the tJava_3? it will be helpful for us to locate the problem.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] NullPointerException globalVar

This is the code
/**
* stop
*/
NB_ITERATE_tJava_3++;
/**
* start
*/
ok_Hash.put("tJava_3", false);
start_Hash.put("tJava_3", System.currentTimeMillis());
currentComponent = "tJava_3";
int tos_count_tJava_3 = 0;
/**
* stop
*/
/**
* start
*/
currentComponent = "tJava_3";
tos_count_tJava_3++;
/**
* stop
*/
/**
* start
*/
currentComponent = "tJava_3";
ok_Hash.put("tJava_3", true);
end_Hash.put("tJava_3", System.currentTimeMillis());
if (!globalMap.get("current_year").equals(
String.valueOf((Integer) globalMap
.get("tLoop_4_CURRENT_VALUE")))) {
tSetGlobalVar_1Process(globalMap);
}
if (context.getProperty("current_year").equals(
String.valueOf((Integer) globalMap
.get("tLoop_4_CURRENT_VALUE")))) {
tRunJob_1Process(globalMap);
}
/**
* stop
*/
Community Manager

Re: [resolved] NullPointerException globalVar

Hi
context.getProperty("current_year").equals(
String.valueOf((Integer) globalMap
.get("tLoop_4_CURRENT_VALUE")))

The problem is caused by this code, it returns a null value, modify it to the below code will work, because you use a global var to store the value on tJava_4.
((String)globalMap.get("current_year")).equals(
String.valueOf((Integer) globalMap
.get("tLoop_4_CURRENT_VALUE")))
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] NullPointerException globalVar

Thanks that's work now !
Regards