One Star

tJavaRow : null pointer exception with length() method

Hi ,
I built the job tFileInputExcel ------> tJavaRow ----> tLogRow
I am testing length of the column in the tJavaRow component with String chaine = input_row.Column1 then lg = chaine.length() but this latter is generating a null pointer exception.
Here enclosed 3 screenshots (job , tJavaRow code and null pointer exception error)

With best regards,
Yves.
6 REPLIES
One Star

Re: tJavaRow : null pointer exception with length() method

Maybe input_row.Column1 is null.
You can try : if (chaine!=null) { lg = chaine.length(); }
regards,
One Star

Re: tJavaRow : null pointer exception with length() method

Hi ,
I did this test as well but it fails as well.
A s soon as I manage input_row.Column1 with length() method or != null the result is null pointer exception.
Best regards,
Yves.
One Star

Re: tJavaRow : null pointer exception with length() method

Hi
try if (!Relational.ISNULL(input_row.Column1)){
}
One Star

Re: tJavaRow : null pointer exception with length() method

This will prevent even if that column have blank space.
if(input_row.Column1!=null && input_row.Column1.trim().length()>0){
String a = input_row.Column1.length();
}
One Star

Re: tJavaRow : null pointer exception with length() method

Hi ,
I experienced the following if (!Relational.ISNULL(input_row.Column1)) suggested by lijolawrance and it works fine.
Thank you veru much.
Best regards,
Yves.
Community Manager

Re: tJavaRow : null pointer exception with length() method

Hi Yves
Glad to hear that, thanks for your feedback!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business