TOS jobs vs external libraries

One Star

TOS jobs vs external libraries

Hi,
I am wondering if I can use external libraries in TOS jobs and/or routines and how.
Indeed I am working in a java environment, I do have a Spring environment setup with lots of functionalities up and running, and it would be quite nice if I could embed, reuse and then manipulate my java objects (managers, DAOs, POJOs, etc) in the TOS java routines.
It would certainly prevent me from duplicating functionalities and having to maintain twice the code in several environments (Eclipse + TOS).
I saw that when you create a routine you can associate some external libraries but I didn't get exactly what it is intended for.
Can it be used to embed external / custom jar files ? How am I supposed to use this feature ?
I also tried to link my '.Java' project with an eclipse userlibrary that we use, but since '.Java' is a dynamic java project my configuration gets screwed at compilation time. I know I am not supposed to do it this way but I was looking for a workaround so that I am able to load my Spring context in a job.
Has anybody already tried that kind of stuff ?
Any lights appreciated
Employee

Re: TOS jobs vs external libraries

Hello
Can it be used to embed external / custom jar files ?

Yes
How am I supposed to use this feature ?

Write your routine like a wrapper to help you to use your own library
Regards
Michaël.
One Star

Re: TOS jobs vs external libraries

Write your routine like a wrapper to help you to use your own library

Then how can I put my own libraries in the routine's classpath ?
When I use the 'Edit Routine Libraries' feature, it looks like my objects are not recognized (no auto-completion, compilation errors, etc)...
Thx
Employee

Re: TOS jobs vs external libraries

Currently, there is no completion in routines.
Compilation errors should not present.
That's a bit tricky but can you try to refresh the modules view ?
Michaël.
One Star

Re: TOS jobs vs external libraries

Currently, there is no completion in routines.

Well, I do use a workaround : I use the 'Navigator' tab, open the underlying java file and I get an unbridled eclipse java editor...
That's a bit tricky but can you try to refresh the modules view ?

The 'Refresh view' button fails, but there is a workaround : register the jar file linked to your routine (in the Modules view it does not seem to be working by the way), it gets copied in the '%TOS_HOME%/java/lib' folder, then close TOS and reopen it, the modules list gets reinitialized, done.
Altogether I guess a few points could be optimized about java editing, here's a draft list :
- Having access to the eclipse native java editor functionalities when you have to write some java code
- The issue when you link an external jar file could be fixed ('Generation Engine Initialization', feature could be called again when you link some new jar files + the 'Refresh view' button for the 'Modules' view should be functional)
- Having the ability to link an external jar file without having it copied into the TOS/java/lib folder (that would mean being able to have a specific classpath per job, routine or TOS instance) so that the jar configuration can be independent from the TOS configuration (it also can help when you link the TOS jobs with a full existing java environment, preventing from jar/code duplication + maintainance issues for instance)
Thanks,
Gaël
Employee

Re: TOS jobs vs external libraries

About your draft list:
- Having access to the eclipse native java editor functionalities when you have to write some java code
=> done for the 2.2 M2 for the routine (even if i think other functionalities will be added later), planned also to be modified on the 2.1.
- The issue when you link an external jar file could be fixed ('Generation Engine Initialization', feature could be called again when you link some new jar files + the 'Refresh view' button for the 'Modules' view should be functional)
=> Need to resolve this for the 2.1, and there is still some things to fix on the 2.2 also now. I will add directly on the bugtracker.
- Having the ability to link an external jar file without having it copied into the TOS/java/lib folder (that would mean being able to have a specific classpath per job, routine or TOS instance) so that the jar configuration can be independent from the TOS configuration (it also can help when you link the TOS jobs with a full existing java environment, preventing from jar/code duplication + maintainance issues for instance)
=> I'm not sure if that's what you're looking for, but have you seen in the Preferences > Talend > Libraries? you can setup another path, so you can keep the same after no matter the version of TOS.
Nicolas.
One Star

Re: TOS jobs vs external libraries

Waiting for the 2.2 M2 then !!
About the 'Preferences / Talend' tip, thanks it sure helps !
It still goes with one and only classpath (no way I can specify a jar file that is generated by another java project for instance) but at least it gets connected with my source (which is under version control) instead of my TOS release
Gaël
One Star

Re: TOS jobs vs external libraries

I have created a user-defined java routine that uses a class from my own custom jar file, "custom.jar"
I tried puttting custom.jar in C:\TOS-Win32-r21383-V3.0.3\lib\java folder but when I run the job, the build fails - cannot resolve my routine. Does anyone know the exact steps I need to take to integrate my custom.jar into the Talend environment?
One Star

Re: TOS jobs vs external libraries

I found the answer in a posting by mhirt:
Hello
Make a right click on your routine will allow you to "edit routine libraries".
Import your jar using this wizard.
Regards,
Michaël.
One Star

Re: TOS jobs vs external libraries

Hi All,
I have the same problems that i need to save my jars into the different place than TOS/lib/java.
I use TOS 3.2.2 and i did all that was written here (i mean i put my path in Preference->Talend->Lib), but when i try to declare my class let's call it com.mycl.mycl so it was colored in red cause my class cannot be resolved.
PS: i saw my jar file in Module view as "User Unused Module"
So what i did wrong ?
Could some one help me with this ?
Regards,
shura
Community Manager

Re: TOS jobs vs external libraries

Hello Shura
There are two ways of referencing the external jars,
1)As rcktan done, create a routine and import external jars into the routine, and then calll the routine in job.
2)Using tLibraryLoad component to load the jar at the begininig of job.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: TOS jobs vs external libraries

Hi Shong,
Thanks for you quick answer.
Another question: in both cases that you wrote i need to attach jar file itself the question : is this possible
to gave only path and TOS will import all the jars that i have instead that i should to attach all the jar one by one ?
Question about TOS 3.2.3: what is the difference between TOS 3.2.2 and 3.2.3 ?
Thanks a lot for the help.
Regards,
Shura