NullPointerException in tMap

One Star

NullPointerException in tMap

Hello,
I have need to update a database table of our establishments with an other database organized with an other way.
The job is in (figure 4) with the running tMap in (figure 1). The result is a list of establishments and caracteristics.
The output table is with one entry per establishment with all the caracteristics.
I have then the tMap in (figure 2) with the error in (figure 3).
Thanks for help.
I use TOS 2.3.1 in java.
One Star

Re: NullPointerException in tMap

Hi,
Could you show the code returning the exception ?
NullPointerException means that you are trying to manipulate an object which doesn't exists
You may add a condition in your treatment (if myObject == null) or a try/catch clause
Regards
Community Manager

Re: NullPointerException in tMap

Hello
Yes, maverick is right.If you get an null point exception, you need to hand the null value on an object. read this 2656.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: NullPointerException in tMap

Excuse me but your answers do not help me.
I have the following entry datas:
ETS_NOM ETS_ID CAR_CODE FAM_ID OBC_VALEUR
M.E.C.S. St Pie X|8|CAPACITE|4|54|
M.E.C.S. St Pie X|8|MIXITE|4|Garçons|
M.E.C.S. St Pie X|8|DIO_DIOCESE|4|70|
M.E.C.S. St Pie X|8|MIN_MINISTERE|4|6|
M.E.C.S. St Pie X|8|HABILITE|4|56|
M.E.C.S. St Pie X|8|AUTORISE|4|84|
I.E.S. St Pie X|9|CAPACITE|4|34|
I.E.S. St Pie X|9|MIXITE|4|Garçons|
I.E.S. St Pie X|9|DIO_DIOCESE|4|70|
You see that the ETS_NOM="I.E.S. St Pie X" has no entry for CAR_CODE="MIN_MINISTERE" for exemple
In the output table I have a column for each CAR_CODE to fill. The column to fill are:
ETS_NOM, ETS_ID, CAPACITE, MIXITE, DIO_DIOCESE, MIN_MINISTERE, HABILITE, AUTORISE
The tMap falls in error because in the output table column MIN_MINISTERE I have written:
CAR_CODE == "MIN_MINISTERE" ? OBC_VALEUR : null
But MIN_MINISTERE does not exists in the first line and doesn't exist for "I.E.S. St Pie X".
Employee

Re: NullPointerException in tMap

Hi mamouroux,
Could you explain a little bit more your test ?
In java if you try to test if CAR_CODE is equal to "MIN_MINISTERE", you need to replace == to .equals("CHARACTER_CHAIN_TO_TEST")
For your exemple :
CAR_CODE.equals("MIN_MINISTERE") ? OBC_VALEUR : null
In this exemple : if CAR_CODE is equal to "MIN_MINISTERE"
then the column value will be the value of OBC_VALEUR
else the column value will be null
Best regards;
One Star

Re: NullPointerException in tMap

Are you sure that your CAR_CODE always have a value ?
In your code line, if CAR_CODE is null, you may get a nullPointerException error
Try to replace your code line by :
CAR_CODE != null ? (CAR_CODE.equals("MIN_MINISTERE") ? OBC_VALEUR : null) : null
Employee

Re: NullPointerException in tMap

Therefore, you can type more simple syntax:
"MIN_MINISTERE".equals(CAR_CODE) ? OBC_VALEUR : null
Then, NullPointerException will never occur because of CAR_CODE is null.

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.