How to resolve a Talend Execution failed due to access is denied error

Have Talend Open Studio running on a Windows server, however, when we run a job, it gives an error similar to the below:

Execution failed : Failed to generate code.
[No .class file created for file org\talend\designer\codegen\translators\processing\TMapMainJava$1.class in C:/Talend/TOS_DI-Win32-r111943-V5.4.1/workspace/.JETEmitters/runtime because of an IOException: C:\Talend\TOS_DI-Win32-r111943-V5.4.1\workspace\.JETEmitters\runtime\org\talend\designer\codegen\translators\processing\TMapMainJava$1.class (Access is denied)

It turns out that the windows file permissions are not set correctly, by giving the Windows Users Full permissions to the file mentioned in the error message, the error resolves. Note that if this is the case there may be a number of files with the wrong permissions.

Multiple ternary expressions

This is how to use Talend to concatenate multiple columns (fields) into one field neatly.

Say we have three fields, row1.field1, row1.field2, row1.field3 that we want to insert into a output.notes column.

In the tMap component, use the following expression:

(StringHandling.LEN(row1.field1) > 0 ? "Field 1: "+row1.field1+" " : "")+(StringHandling.LEN(row1.field2) > 0 ? "Field 2 "+row1.field2+" " : "" )+(StringHandling.LEN(row1.field3) > 0 ? "Field 3 Address: "+row1.Address+", "+row1.Suburb+", "+row1.State+", "+row1.Pcode+" " : "")

What this does is check to see if field1 has anything in it (i.e. has a length longer than 0), if it does, it adds the field and a space after it to buffer it against the next field. If it doesn’t, then it doesn’t insert anything. It then does the same for fields 2 and 3.

Updated 2014-01-30 12h49m to put the code in a html code block and fix the double quotes which had been ‘smartly’ but wrongly changed.

Using a ternary operator in Talend Open Studio

I’m currently preparing some data for import into SugarCRM for a client. The source data has a column that contains the given names (i.e. “Jane Mary”) and a second column containing the surname (i.e. “Doe”).

Using Talend Open Studio we want to separate the given names into first_name and middle_names columns. So, how do we split the first name and middle name?

By using in the tMap component an expression.

For the first name, we do this:


StringHandling.INDEX(row1.GivenNames," ") > 0 ? StringHandling.LEFT(row1.GivenNames,StringHandling.INDEX(row1.GivenNames," ")) : row1.GivenNames

And to extract the middle name/s we use this expression:


StringHandling.INDEX(row1.GivenNames," ") > 0 ? StringHandling.RIGHT(row1.GivenNames,StringHandling.LEN(row1.GivenNames)-StringHandling.INDEX(row1.GivenNames," ")–1) : ""

This type of expression are known as a ternary operationsee examples.

The basic format of a ternary operation is this:

test condition ? do this if true : do this if false

2013-10-30 Open loops

large__8971665708

Off-topic, well, on topic, or both maybe: I’m finding it useful to write these ‘open loops’ as it’s just a bunch of links that I want to come back to, without losing them. Quite frankly it’s easier to find them here on my blog than anywhere else. I am the intended reader of these posts, but do let me know if your find them useful at all.

photo credit: MOLLYBLOCK via photopin cc