• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » how to Handl nullPointerException in tFilterRow

#1 2012-05-24 12:33:02

Piero001
Member
Registered: 2012-05-07
Posts: 37

how to Handl nullPointerException in tFilterRow

hi community,

if have a problem with a NullPointerException in tFilterRow

Error log:

Code:

Exception in component tFilterRow_1
java.lang.NullPointerException
    at haltern.journalentwicklung_0_1.journalentwicklung.tFileInputDelimited_1Process(journalentwicklung.java:3547)
    at haltern.journalentwicklung_0_1.journalentwicklung.runJobInTOS(journalentwicklung.java:4517)
    at haltern.journalentwicklung_0_1.journalentwicklung.main(journalentwicklung.java:4385)

Job code:

Code:

3547: row1.column1.equals("X")
4517: tFileInputDelimited_1Process(globalMap);
4385: int exitCode = testjobClass.runJobInTOS(args);

the input of column1 is defined as String. The input can be "x" or "y" but it could be possible that some rows are null so I set column1 as Nullable. Should I add some code to the advanced

I use the advanced mode of tFilterRow: row1.column1.equals("X")

should i write more? Can you help me with the problem?

Regards,


Piero

Offline

#2 2012-05-24 12:40:51

avdbrink
Member
Company: Conspect Consulting & ICT
Registered: 2010-11-08
Posts: 360
Website

Re: how to Handl nullPointerException in tFilterRow

Hi Piero,

It looks like your column1 is null. You could prevent this from happening by using a tMap in front of the tFilterRow where you map all columns with automap and change the column1 output to the following:

Code:

(!row1.column1 == null) ? row1.column1 : ""

Hope this helps.

Regards,
Arno

Offline

#3 2012-05-24 14:16:10

Piero001
Member
Registered: 2012-05-07
Posts: 37

Re: how to Handl nullPointerException in tFilterRow

Hi Arno,

thank you very much for your help again!
I tried your code but it says now: The operator ! is not defined for the typ String

what should I do?

regards,

Piero

Offline

#4 2012-05-24 14:25:20

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1121

Re: how to Handl nullPointerException in tFilterRow

! Relational.ISNULL(row1.column1) ? row1.column1 : ""

Offline

#5 2012-05-24 14:38:21

avdbrink
Member
Company: Conspect Consulting & ICT
Registered: 2010-11-08
Posts: 360
Website

Re: how to Handl nullPointerException in tFilterRow

Hi Piero,

I'm very sorry, my mistake. Janhess's code will work as will this code:

Code:

(row1.column1 != null) ? row1.column1 : ""

Regards,
Arno

Offline

#6 2012-05-24 14:55:32

Piero001
Member
Registered: 2012-05-07
Posts: 37

Re: how to Handl nullPointerException in tFilterRow

Hi Arno and janhess,

Thank you very much. With the code the Job is working very well now smile

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » how to Handl nullPointerException in tFilterRow

Board footer

Powered by FluxBB