tFileInputXML couldn't read stream set in globalMap.

One Star

tFileInputXML couldn't read stream set in globalMap.

Hi,
Below is my requirement.
I need to read a XML passes as part of command promt.
After reading it, pass it to a tmap to create a true and false flow.
In true flow, the xml read has to passed to a tFileInputXML --> tWriteXMLFiled --> tLogRow.
I am able to create the flow, but the problems occurs in tFileInputXML.
For tFileInputXML i have to read the xml from the inputStream and not from a file.
I have tried using tJava, tJavaFlex and tJavaRow to set the inputstream in the context as follows.
-- java code
java.io.InputStream is2 = new ByteArrayInputStream(context.input.getBytes());
globalMap.put("iStream", is2);
-- tFileInputXML
FileName/Stream value --> ((java.io.InputStream)globalMap.get("iStream"))
How much ever i try, the stream I set doesn't get picked up in the tFileInputXML.
When I change FileName/Stream value --> to a local file. Things are working fine. So my only problem is how to connect tMap to tFileInputXML by passing the data as stream.
Need your assistance on how to achieve this.
Thanks,
Padmaraj.
Moderator

Re: tFileInputXML couldn't read stream set in globalMap.

Hi,
I suspect something wrong with your java code
It seems that:
java.io.FileInputStream is2 = new java.io.FileInputStream(
"F:/Talend/5.3/Talend-Studio-r101418-V5.3.0NB/workspace/in.xlsx",
false);

globalMap.put("key", is2);
tFileInputXML
FileName/Stream value --> ((java.io.FileInputStream)globalMap.get("key"))

Your job design is right, for things are working fine when you change it into local file.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: tFileInputXML couldn't read stream set in globalMap.

Hi,
I suspect something wrong with your java code
It seems that:
java.io.FileInputStream is2 = new java.io.FileInputStream(
"F:/Talend/5.3/Talend-Studio-r101418-V5.3.0NB/workspace/in.xlsx",
false);

globalMap.put("key", is2);
tFileInputXML
FileName/Stream value --> ((java.io.FileInputStream)globalMap.get("key"))

Your job design is right, for things are working fine when you change it into local file.
Best regards
Sabrina

Hi,
I guess i should have explained things bit more.
Attached is my flow design.
Java code at tJava_1:
java.io.InputStream is = new ByteArrayInputStream(context.input.getBytes());
globalMap.put("iStream", is);
tFileInputXML_1 : ((java.io.InputStream)globalMap.get("iStream"))

The above works fine without any issues. tFileInputXML_1 is able to read the value set in globalMap from tJava_1.
Where as the same code used in tJava_2 as below,
java.io.InputStream is = new ByteArrayInputStream(context.input.getBytes());
globalMap.put("iStream", is);
is not read by, tFileInputXML_2. --> ((java.io.InputStream)globalMap.get("iStream"))
There is no output of rows from tFileInputXML_2.
Kindly help.
Thanks,
Padmaraj.
Community Manager

Re: tFileInputXML couldn't read stream set in globalMap.

Hi Padmaraj
About your job design, I have two suggestions:
1. use oncomponentOK replace iterate.
2. You don't need to add the same code on tJava_2 again, remove tJava_2 from your job if it don't do anything in addition to add the same code as tJava_1.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business