Error importing external jar in a custom component

Highlighted
Four Stars

Error importing external jar in a custom component

Hello,

I'm trying to create a component for modbus communication. I run Talend ESB 5.5.1
When I try to instanciate a objet of the external jar EasyModbusJava.jar I face an error: 

 

Exécution en erreur :Échec de la génération du code.
[----------
1. ERROR in C:\Workspace_talend_esb\.JETEmitters\src\org\talend\designer\codegen\translators\laita\TModbusBeginJava.java (at line 35)
de.re.easymodbus.modbusclient.ModbusClient modbusClient = new de.re.easymodbus.modbusclient.ModbusClient("192.168.0.10",502);
^^
de cannot be resolved to a type

 


Jar is referenced in tModbus_java.xml:

 

<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="modbus" MODULE="EasyModbusJava.jar" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>


The jar has been copied in:

TalendDirectory/plugins/org.talend.designer.components.localprovider_5.5.1.r118616/components/tModbus

and

TalendDirectory/lib/java directory

 

An extract of tModbus_begin.javajet:

<%@ jet 
imports="
org.talend.core.model.process.INode 
org.talend.core.model.process.ElementParameterParser
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.Map
java.util.List
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();

String cid = node.getUniqueName();
de.re.easymodbus.modbusclient.ModbusClient modbusClient = new de.re.easymodbus.modbusclient.ModbusClient("192.168.0.10",502);


I've searched on you forum but didn't find anything that help me

MadProf

 


Accepted Solutions
Community Manager

Re: Error importing external jar in a custom component

Hi
Have a try to import the class in the Import section:
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.Map
java.util.List
de.re.easymodbus.modbusclient.ModbusClient
"
%>
If it still does not work, would you mind sending your custom component as well as external jar to me for testing?

Regards
Shong

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

All Replies
Four Stars

Re: Error importing external jar in a custom component

I've tried to execute the same code in a tJava with tLibrary to load the external jar, and it worked fine, but in my custom component the library isn't recognized..
Four Stars

Re: Error importing external jar in a custom component

Nobody has an idea ?

Community Manager

Re: Error importing external jar in a custom component

Hi
Have a try to import the class in the Import section:
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.Map
java.util.List
de.re.easymodbus.modbusclient.ModbusClient
"
%>
If it still does not work, would you mind sending your custom component as well as external jar to me for testing?

Regards
Shong

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

Re: Error importing external jar in a custom component

Thx you for your help Shong, now it works Smiley Wink

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 1

Learn how to do cool things with Context Variables

Blog

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog