[resolved] [OutputFileComponent] Error occurs when rows is null

One Star

[resolved] [OutputFileComponent] Error occurs when rows is null

Hello. For my process, my mapping component return no rows. This case can be happen with our datas.
How can i stop the process to don't have this error, ingore this error, or better, can i define settings for the tAdvanceFileOutputXML to not trying to generate a file with null or no rows input.  
I set only to true for my component the settings :
[list=*]

  • Do not generate empty file

 

  • Create directory if does not exist



Exception in component tAdvancedFileOutputXML_1
java.lang.NullPointerException


https://www.talendforge.org/forum/img/members/316269/blob_20150909-1108.png

https://www.talendforge.org/forum/img/members/316269/blob_20150909-1112.png


Accepted Solutions
Community Manager

Re: [resolved] [OutputFileComponent] Error occurs when rows is null

Hi
Take a look at this article to learn how to active these technical components (tHashInput and tHashOutput). tJavaFlex should be available by default, I don't understand why you can't find it.

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post


All Replies
Community Manager

Re: [resolved] [OutputFileComponent] Error occurs when rows is null

Hi
You can check the number of rows before writing the data to file. For example
....main--tHashOutput-main-tJavaFlex
  |
onsubjobok
  |
tJava--runIf--tHashInput--main--tAdvancedFileOutputXML
in the begin part of tJavaFlex, define a counter with int type.
int counter=0;
in the main part:
counter=counter+1;
in the end part, store the counter to a global variable
globalMap.put("counter",counter);

on tJava, get the row number and check if greater than 0.
int counter= (Integer)globalMap.get("counter");
if(counter>0){
globalMap.put("hasData",true);
}else{
globalMap.put("hasData",false);
}
Set the condition of runIf link as:
(Boolean)globalMap.get("hasData")

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] [OutputFileComponent] Error occurs when rows is null

I work with TOS for ESB 6.1.0.20150815_15_15-M1.
I have not these component tHashInput, tHashOutput and tJavaFlex :s
I try too to attach the tJava-RunIf on many component, but he don't want. On which component can i link the RunIf ?
Community Manager

Re: [resolved] [OutputFileComponent] Error occurs when rows is null

Hi
Take a look at this article to learn how to active these technical components (tHashInput and tHashOutput). tJavaFlex should be available by default, I don't understand why you can't find it.

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post

One Star

Re: [resolved] [OutputFileComponent] Error occurs when rows is null

Oups, i have the tJavaFlex but it does not appear when i write his name. I must take it from tools.
For next, all work fine.

Thanks for the help.
In our project, not only developpers will used Talend. If i can give a suggestion, it will be great if Talend improve a component for counting number of row to avoid us writing java code.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog