How to add java libraries to fix ClassNotFoundException when running a job from Studio?

Five Stars

How to add java libraries to fix ClassNotFoundException when running a job from Studio?

Setup:

Talend Open Studio for Data Integration Version: 7.2.1

Win 10 64-bit

 

My team is working on a POC for replacing our existing ETL tool with Talend and we are stuck trying to resolve ClassNotFoundException for various java libraries when trying to run our jobs and routines (even very simple ones) from within the Studio. Here are two that we are having trouble with:

 

1) Job using tJMSInput complaining about not finding org.apache.activemq.jndi.ActiveMQInitialContextFactory.

 

2) Routine trying to connect to the SQL Server database complaining about not finding com.microsoft.jdbc.sqlserver.SQLServerDriver. Routine code is as follows:

 

// the sql server driver string

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

 

// the sql server url

String url = "<db url string>";

    

// get the sql server database connection

conn = DriverManager.getConnection(url,"<username>", "<password>");

           

// now do whatever you want to do with the connection

String sql = "<insert sql here>";

stmt = conn.prepareStatement(sql);

     

stmt.setInt(1, errorCode); 

ResultSet rs = stmt.executeQuery(sql);

 

We have been chasing our tails trying to figure out how to get Talend Studio to run our test-jobs and any guidance would be much appreciated

 

Community Manager

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?

Hi
First, what is your JDK version, it requires Java 8 or 11, refer to this documentation.
https://help.talend.com/reader/LttzgwOFiGHMMQZAUlZfMg/ax8~2xFLImjTrRvgRXb3Ww

tJMSxxx components requires jms.jar to work, make sure this jar has been installed, you can go to Windows-->Show views-->Talend-->Modules, and check if the required jars have been installed for tJMSxxx components.

Talend Studio has built-in SQL Server components such as tMSSQLInput that you can use to integrate with MS SQL Server.

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

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?

Thank you for the prompt response. I am on Java 8.

 

I'm not finding "Windows-->Show views-->Talend-->Modules" in Talend Studio for Data Integration, but I did find it under "Windows-->Show views-->Other-->Modules".

 

Under modules it appears jms.jar is installed. I still get the runtime error. Please see attached images

talend_jms_in_modules_view.pngtalend_jms_exception_at_runtime.png

Community Manager

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?

Which module do you select in the Module list? it should be activemq-all.jar.
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?


@shong wrote:
Which module do you select in the Module list? it should be activemq-all.jar.

Weird, looks like my reply post was deleted. I replied that I don't see activemq-all.jar in the module list, only activemq-client-5.15.9.jar. I selected this and ran it and now I get the following error:


Exception in thread "main" java.lang.NoClassDefFoundError: javax/management/j2ee/statistics/Stats

Employee

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?

Hi,

 

    Ideally the component will prompt if some jar is missing (like the one below) and it will prompt you to install those missing jars.

image.png

 

Didn't it happen in your case?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Five Stars

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?


@nikhilthampi wrote:

Ideally the component will prompt if some jar is missing (like the one below) and it will prompt you to install those missing jars.

 

Didn't it happen in your case?


No, Talend Studio thinks it has everything it needs, looks like. I see no issues flagged anywhere until I run the job, then it fails.

Employee

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?

Hi,

 

    As a contingency plan till Shong comes back, you can use tLibraryLoad to add the libraries manually to the job. Please make sure that you are adding the import details in the advance section of the component so that associated classes will be available.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Eight Stars

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?

Hi

I face the same problem with sap jdbc and routes in Talend ESB. 

ngdbc.jar is correctly installed in my modules : 

2019-11-26 09_29_11-Talend Open Studio for ESB (6.4.1.20170623_1246) _ GFC (Connexion_ Dev).png

And I can connect in a medata DB connexion with the "test" button. 

 

Now we need to connect in a route, I wrote this : 

 

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

String connectionString = "jdbc:sap://myserver:30015?currentschema=\"SBO_ES53_RUN6\"";

//Class.forName("com.sap.db.jdbc.Driver");
    	
Connection connection =  
DriverManager.getConnection(connectionString, "myuser", "mypassword");

and face the same issue "No suitable driver found for jdbc:sap://..."

 

The problem is com.sap.db.jdbc.Driver is unknown if I uncomment the class.forName line. And I can't import it.

 

I also tried copying manually my ngdbc-2.4.64.jar file in Studio\plugins\org.talend.designer.camel.components.localprovider_6.4.1.20170623_1246\lib , and also directly in my JVM lib directory.

 

The same code works perfectly in a standalone Eclipse IDE with jar import to the project.

Loko

Eight Stars

Re: How to add java libraries to fix ClassNotFoundException when running a job from Studio?

I can have it work if I use cTalendJob in my route and in that job use tLoadLibrary to load my jar. 

But this is pretty awfull workaround, just to be sure the issue comes from Talend route conf and not from the jar itself.

2019 GARTNER 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

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