tFileList to tIteratetoFlow - Can't convert Object to String

One Star

tFileList to tIteratetoFlow - Can't convert Object to String

new to Talend and trying to evaluate it against several other ETL tools in a short time span. Using Talend 3.0 on a Linux system.
I feel like an idiot at the moment. I was following an example from the Components_RG_30c_EN.pdf guide (Scenario: Transforming a list of files as data flow) and I've run into the problem that my job is throwing an error that it cannot convert from Object to String.
Job is using Java not Perl.
I have a tFileList listing a directory, FileList Type=Files, Case Sensitivity=No, Use Glob Expression=Yes, Filemask="*.txt". tFileList links to tIterateToFlow via iteration link. tIterateToFlow schema has one column defined "filename" who gets it's value from globalMap.get("CURRENT_FILE"). I have also tried various other variables including:
Help is much appreciated.

Re: tFileList to tIteratetoFlow - Can't convert Object to String

One Star

Re: tFileList to tIteratetoFlow - Can't convert Object to String

just to update. I seem to have come up with a solution. If I'm wrong, by all means, please correct me.
So I tried the exact same thing using perl instead of Java and it worked just fine. Since I prefer to use Java if at all possible, I kept digging and found out that it was all pretty much centered around the variable value in the tIterateToFlow mapping. When I edited the schema in tIterateToFlow and created a new column "filename", it automatically populated the mapping value with globalMap.get("CURRENT_FILE"). Two things seem to be wrong here
a) globalMap.get() returns Object, not String causing a java.lang.Exception
b) "CURRENT_FILE" is not a value recognized (at least not in my job).
Clearing the Value, I used CTRL+Space to scroll though the list of available variables and found that "tFileList_1_CURRENT_FILE" looked promising. The problem there is that by selecting this variable it populated with ((String)globalMap.get("tFileList_1_CURRENT_FILE")). Almost correct, but the extra parens caused null values to be returned.
What works for me is:
One Star

Re: tFileList to tIteratetoFlow - Can't convert Object to String

haha, too late on the draw on my part. Thanks John.
One Star

Re: tFileList to tIteratetoFlow - Can't convert Object to String

Java is very type save and it is not possible to overload a method to return different types. So globalMap.get() will always return a Object (all types in Java are derived from Object. But to use it you need to do a cast. This is done by setting the needed type in parentheses in front of the variable (or method).
The extra parentheses should make no problems. Are you sure you haven't changed anything else?
One Star

Re: tFileList to tIteratetoFlow - Can't convert Object to String

I have a problem with tfilelist and iteratetoflow. I work on Windows Seven Pro 64 with TOS 64. I just want to list a directrory in a file like in example in the component guide. The error is the next :
'La méthode tIterateToFlow_1_AI_onSubJobError(Exception,String,Map<String,Objetc>) est indéfinie pour le type NomJob.
I don't understand how a very simple use case can't work. What about stability and test unit of the software? Often with TOS i now what i want and how to make the job (I paid a formation) but it doesn't work. It's very expansive for time (free software????).
One Star

Re: tFileList to tIteratetoFlow - Can't convert Object to String

below a bug (related in 2010 by an other person) and i have the same problème (tos 4.2.2 or TOS 5.0 with Postgresql 9.0). It is very important to can update some record and have a reject fux. For this elementary task i hope talend fix the bug in 2012 or 2013 or 2014 ...Smiley Wink
Can someone have the same problem or a solution? For me using batch with 1line don't work.
The bug :
I want to insert rows in an PostgreSQL database having rejected row to be log in a special file.
I'm using a tPostgresqlOutput with "commit every" 10000, "Die on error" false.
When an error occurs on "insert", all the following rows are rejected with the following message "current transaction is aborted, commands ignored until end of transaction block"
While using tOracleOutput I don't get this kind of error.
I can counter this by setting "commit every" to 1, but is there any other way to save "commit" and go through first SQL error?
--My config :
TOS 4.0.2.r43696
PosgreSQL Database Server 8.2


Join us at the Community Lounge.

Register Now


Talend named a Leader.

Get your copy


Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables


How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration


Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach