Error importing external jar in a custom component

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

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.