Exception - The hash is not initialized : The hash must exist...

One Star

Exception - The hash is not initialized : The hash must exist...

Hi,
I have a job (REST service) to get company information from a database. I use tHashOutput to store the user input in the memory and after database connection is set I read that user input data from memory using tHashInput which then passes the data onto another database component for processing.
It has all worked up until when I tried to test the service using JMeter to simulate multiple users making using the service - the service works at times e.g. success with 10 users and at other times I get the below error with the same number of users:
Exception in component tHashInput_2
java.lang.RuntimeException: The hash is not initialized : The hash must exist before you read from it
I had OnComponentOk links between tHashOutput and tJDBCConnection and between tJDBCConnection and tHashInput components and on advise from another post here on Talend Forum I have deleted the OnComponentOk links between tHashOutput and tJDBCConnection and created a OnSubjobOk link between tRESTComponent and tJDBCConnection. Also I changed the trigger (Linking tJDBCConnection and tHashInput component) from OnComponentOk to OnSubjobOk. 
But I still get the Java error mentioned above.
Please see the screenshot (In parts as uploading the whole screenshot makes it too small here) attached and I would greatly appreciate your help in resolving this issue.
Thanks

Seventeen Stars

Re: Exception - The hash is not initialized : The hash must exist...

You should post the whole job as screenshot. With this picture I cannot spot the problem.
This error happens when you are trying to read before linked tHashOutput has finished the writings -> In any way you have managed to start the reading before the writing has been finished.
One Star

Re: Exception - The hash is not initialized : The hash must exist...

Hi jlolling, I have updated the screenshot now.
Thanks
Seventeen Stars

Re: Exception - The hash is not initialized : The hash must exist...

hi,
you try to read hashmap as soon as dbConnection is Ok, not when your input in hashmap is ok ...
link dbConnection with preJob and on subJobOk from subJob putting data in hashmap
regards
laurent
One Star

Re: Exception - The hash is not initialized : The hash must exist...

Hi Laurent,
First I had:
thashOutput  -> OnComponentOK -> tJDBCConnection -> OnComponentOK-> thashInput  (I had the issue as described in my post above)
Then I changed to:
thashOutput  -> OnComponentOK -> tJDBCConnection -> OnSubjobOK -> thashInput  (Issue still there)
Then I changed to:
tRESTRequest-> OnSubjobOK -> tJDBCConnection -> OnSubjobOK -> thashInput (Issue still there)
I did not want connection pooling to be as part of the prejob but just to check if that resolves the issue I have linked tJDBCConnection with prejob and now have:
thashOutput  -> OnComponentOK  -> thashInput -> tJDBCSP (This now causes a Java NullPointerException at the jJDBCSP component)
While tJDBCConnection is linked with prejob I also tried:
tRESTRequest-> OnSubjobOK -> thashInput -> tJDBCSP (But still get a Java NullPointerException at the jJDBCSP component)
Without the tHashOutput and tHashInput components (Still get the Java NullPointerException)
Please see my screenshot.
Thanks

http://www.talendforge.org/forum/img/members/196945/mini_New_tHash_Problem_Part_4.png.png
http://www.talendforge.org/forum/img/members/196945/mini_New_tHash_Problem_Part_5.png.png
One Star

Re: Exception - The hash is not initialized : The hash must exist...

Hi jlolling,
Please let me know what your thoughts are on my post (#1) which shows the full screenshot.
thanks
Seventeen Stars

Re: Exception - The hash is not initialized : The hash must exist...

It's another error in your DBSp ... check parameter ... one of them is null I guess !
regards
laurent
One Star

Re: Exception - The hash is not initialized : The hash must exist...

Yes laurent, it is the result parameter that is of type RECORD SET in the tJDBCSP component and it is added to the schema in the tXMLMap component and passed onto the tJDBCSP component.
But when I had the tHashOutput and tHashInput components before, result was being added to the schema in tHashInput and passed (Without being assigned any value) onto the tJDBCSP component and I did not get this exception.
Thanks
Seventeen Stars

Re: Exception - The hash is not initialized : The hash must exist...

in your scenario it will better to use tSetGlobalVar I guess as you manage data not flow.
https://help.talend.com/search/all?query=tSetGlobalVar&content-lang=en
regards
laurent