Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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

View solution in original post

4 Replies
Anonymous
Not applicable
Author

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..
Anonymous
Not applicable
Author

Nobody has an idea ?

Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

Thx you for your help Shong, now it works 0683p000009MA9p.png