One Star

[resolved] Problems using StringUtils.isNotBlank

I am having issues using StringUtils.isNotBlank in a map. When running the job I receive the error

'The method isNotBlank(String) is undefined for the type StringUtils'

I have tried different ways of loading in tLibraryLoad
import org.apache.commons.lang.StringUtils;
import static org.apache.commons.lang.StringUtils.*;
import static org.apache.commons.lang.StringUtils.isNotBlank;

I am loading commons-lang-2.6.jar

In the map where I am trying to use the method I specify

StringUtils.isNotBlank(row8.FieldValue)

I am new to Java so I maybe missing something obvious, any ideas?

Do I need to worry about the CLASSPATH?
1 ACCEPTED SOLUTION

Accepted Solutions
Seventeen Stars

Re: [resolved] Problems using StringUtils.isNotBlank

It is often a matter in which order the libraries will be loaded. apache commons library is very often a part of an component and if you depends on a newer version and load your library than you have to take care that this library classes are not already loaded. Classes will be loaded only once per Java start (Talend does not use special class loaders, only the standard class loader) and classes will not be updated due a further load of a library.
I suggest: extract the methods you need and implement them in a routines and you have always the access to your code.
2 REPLIES
One Star

Re: [resolved] Problems using StringUtils.isNotBlank

Feedback.
.
I got this to work, unfortunately I am not sure what made it work. I was getting really frustrated with this so I was trying everything I could think of. I moved the .JAR to the Talend directory, I created a function to load the library and then removed it. I exited and re-opened Talend (I think this is what solved it). Anyway it is now working, I will try and prove this out when I have more time. But basically what I have now is

I used tLibraryLoad in my job with
import org.apache.commons.lang.StringUtils;


Regards,
Derek
Seventeen Stars

Re: [resolved] Problems using StringUtils.isNotBlank

It is often a matter in which order the libraries will be loaded. apache commons library is very often a part of an component and if you depends on a newer version and load your library than you have to take care that this library classes are not already loaded. Classes will be loaded only once per Java start (Talend does not use special class loaders, only the standard class loader) and classes will not be updated due a further load of a library.
I suggest: extract the methods you need and implement them in a routines and you have always the access to your code.