Import external jar using routines

Highlighted
Five Stars

Import external jar using routines

Hello, 

 

I have trouble importing an external jar into my project using a routine.

The problem is I can't use tLibraryLoad because my external jar is meant to evolve. So I don't want to regenerate all the jobs using it every time my external jar changes.

 

What we did was creating a routine called 'Loader', and this routine uses my external jar.

That works perfectly with the studio. But my job won't generate on TAC because it doesn't seem to load my external jar.

 

Here is my loader_0.1.properties : 

 

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:TalendProperties="http://www.talend.org/properties">
  <TalendProperties:Property xmi:id="_YJb14CUQEeeUgcsKuAamXA" id="_YJbO0CUQEeeUgcsKuAamXA" label="loader" creationDate="2017-04-19T16:56:32.830+0200" modificationDate="2017-04-19T16:57:29.824+0200$
    <author href="../../../talend.project#_B9_TACRCEeeSPKLpifn8vg"/>
  </TalendProperties:Property>
  <TalendProperties:ItemState xmi:id="_YJb14SUQEeeUgcsKuAamXA" path="custom"/>
  <TalendProperties:RoutineItem xmi:id="_YJb14iUQEeeUgcsKuAamXA" property="_YJb14CUQEeeUgcsKuAamXA" state="_YJb14SUQEeeUgcsKuAamXA">
    <content href="loader_0.1.item#/"/>
    <imports xmi:id="_gOZK0CUQEeeUgcsKuAamXA" mESSAGE="common_lib" mODULE="my-external.jar" nAME="loader" rEQUIRED="true" urlPath="/opt/common_lib/my-external.jar"/>
  </TalendProperties:RoutineItem>
</xmi:XMI>

The jar is indeed located in /opt/common_lib/ .

 

Here is the beginning of my job.java :

package job_externaljar_0_1;

import routines.DataOperation;
import routines.TalendDataGenerator;
import routines.DataQuality;
import routines.loader;
import routines.Relational;
import routines.DataQualityDependencies;
import routines.Mathematical;

Am I missing something ? 

Is there another way to do what I want to do ?

 

Thanks for your support.


Accepted Solutions
Five Stars

Re: Import external jar using routines

Hi Shong, 

 

I finally got the job done.

The problem was simple : I changed the configuration of Nexus from localhost to its DNS and then it works. 

 

Thanks for your time !


All Replies
Community Manager

Re: Import external jar using routines

Hello 

In studio, right click on routine and select 'Edit routine libraries' option to add external libraries to your routine. 

In TAC, open the configuration page and define the User libraries parameters to specify a repository URL for storing all libraries.

 1.png

 

I don't know if you have followed the same steps, let me know if the problem still exists.

 

Regards

Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: Import external jar using routines

Hello Shong,

 

Thanks for the reply.

I tried that, but it doesn't seem to work.

I've uploaded my external jar in the following directory : 

/opt/talend/tac/Artifact-Repository-Nexus-V2.11.3-01/sonatype-work/nexus/storage/talend-custom-libs

Then I configured the User Libraries in the Configuration page to that exact Nexus Repository.

 

I linked the very same jar using a routine.

So the job is running quite well on the studio, but won't generate on the TAC, even if my jar is located on the right repository on Nexus.

 

I restarted the Commande Line to be sure, but it didn't change much.

 

Have you got an idea ?

 

Community Manager

Re: Import external jar using routines

Hi
The jar should should be loaded automatically to Nexus after you configure the parameters and the dependency libraries are exported also when deploy the job to remote Job server. I have no reasons why you still got the error. Which version of studio are you using? Would you mind sending me the job items and the jar for testing?

Regards
Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: Import external jar using routines

Hi Shong, 

 

I finally got the job done.

The problem was simple : I changed the configuration of Nexus from localhost to its DNS and then it works. 

 

Thanks for your time !

Community Manager

Re: Import external jar using routines

Great, thanks for your feedback and sharing the solution.

----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: Import external jar using routines

Hi ,

Can someone please explain why does this issue occur because of nexus configuration and can it be avoided ?
As the Talend job runs locally why does it need nexus to be up , is there any workaround ?

 

The problem is , in our project it is not uncommon for the nexus server to go down (it would seem strange) , but when that happens we cannot run Talend jobs in our local environment as well.As it gives the error "import data.operation cannot be resolved to a type"

 

Can this be avoided ?

 

Thanks.

Five Stars

Re: Import external jar using routines

Did you find a solution/workaround?, We're having the same problem : once the nexus is down or restarted, we cannot build the jobs anymore because Talend is unable to get the internal libraries.

We have errors like : "the import org.apache cannot be resolved"

Seven Stars

Re: Import external jar using routines

Yes , Restarting Talend works for me , hope this fixes your issue as well. 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

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 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog