Issue with JAR files when using a custom component

One Star

Issue with JAR files when using a custom component

Hi we've developed a component to create online credit card payments (using payzen PSP solution)
see http://talendforge.org/exchange/index.php?eid=391&product=tos&action=view&nav=1,1,1
in this component we have some Jar files they are described in the xml file
pCreateMailOffer_java.xml
<CODEGENERATION>
<IMPORTS>
<IMPORT MODULE="PayementOfferV1a.jar" NAME="WSV3" REQUIRED="true"/>
<IMPORT MODULE="Signature.jar" NAME="Signature" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
and the Jar files are in the component zip
when running the jobs
see example http://code.google.com/p/payzen-components-for-talend/wiki/pCreateMailOffer_Exemple
There is an error unless the jar are copied in the \TOS-Win32-r63143-V4.2.2\lib\java\ directory
Did I miss something in my component design ?
Community Manager

Re: Issue with JAR files when using a custom component

Hi
Sorry for delay, don't know you have fixed the problem?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Issue with JAR files when using a custom component

Hello, I had the exact same issue with custom developed components.
Sometimes the jars are not copied automatically, it's probably a bug, the workaround is to copy them manually in the lib/java directory.
Moreover I am quite sure they are NOT copied if you create a new version of your jar with the same name an d the old one is already in the lib/java... the old file is not replaced.
I detected this at least in Linux, some colleagues installed the same component in windows and apparently the jar was copied for them.
We should probably open a bug in Jira for this
One Star

Re: Issue with JAR files when using a custom component

Hello,
I strarti coding talend components. Can you please tell me or show example about the import of jar into the component. I am using Talend 5.2.2 and i lost so many time to achieve.

Regards
Jruf.
Community Manager

Re: Issue with JAR files when using a custom component

Hi Jruf
Put the jars in the component folder, and then declare the import in the XML descriptor file for example, tFileInputExcel_java.xml
	<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="Java_Excel" MODULE="jxl.jar" UrlPath="platform:/plugin/org.talend.libraries.jexcel/lib/jxl.jar" REQUIRED_IF="(VERSION_2007 == 'false')" />
<IMPORT NAME="dom4j" MODULE="dom4j-1.6.1.jar" UrlPath="platform:/plugin/org.talend.libraries.dom4j-jaxen/lib/dom4j-1.6.1.jar" REQUIRED_IF="(VERSION_2007 == 'true')" />
<IMPORT NAME="geronimo-stax-api" MODULE="geronimo-stax-api_1.0_spec-1.0.jar" UrlPath="platform:/plugin/org.talend.libraries.apache.axis2/lib/geronimo-stax-api_1.0_spec-1.0.jar" REQUIRED_IF="(VERSION_2007 == 'true')" />
<IMPORT NAME="log4j" MODULE="log4j-1.2.15.jar" UrlPath="platform:/base/plugins/org.apache.log4j_1.2.15.v201012070815.jar" REQUIRED_IF="(VERSION_2007 == 'true')" BundleID="" />
<IMPORT NAME="poi" MODULE="poi-3.8-20120913_modified_talend.jar" UrlPath="platform:/plugin/org.talend.libraries.excel/lib/poi-3.8-20120913_modified_talend.jar" REQUIRED_IF="(VERSION_2007 == 'true')" />
<IMPORT NAME="poi-ooxml" MODULE="poi-ooxml-3.8-20121127_modified_talend.jar" UrlPath="platform:/plugin/org.talend.libraries.excel/lib/poi-ooxml-3.8-20121127_modified_talend.jar" REQUIRED_IF="(VERSION_2007 == 'true')" />
<IMPORT NAME="poi-ooxml-schemas" MODULE="poi-ooxml-schemas-3.8-20120326.jar" UrlPath="platform:/plugin/org.talend.libraries.excel/lib/poi-ooxml-schemas-3.8-20120326.jar" REQUIRED_IF="(VERSION_2007 == 'true')" />
<IMPORT NAME="poi-scratchpad" MODULE="poi-scratchpad-3.8-20120326.jar" UrlPath="platform:/plugin/org.talend.libraries.excel/lib/poi-scratchpad-3.8-20120326.jar" REQUIRED_IF="(VERSION_2007 == 'true')" />
<IMPORT NAME="xmlbeans" MODULE="xmlbeans-2.3.0.jar" UrlPath="platform:/plugin/org.talend.libraries.apache.xml/lib/xmlbeans-2.3.0.jar" REQUIRED_IF="(VERSION_2007 == 'true')" />
<IMPORT NAME="simpleexcel" MODULE="simpleexcel.jar" UrlPath="platform:/plugin/org.talend.libraries.excel/lib/simpleexcel.jar" REQUIRED_IF="(VERSION_2007 == 'true') AND GENERATION_MODE == 'EVENT_MODE')" />
</IMPORTS>
</CODEGENERATION>

Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seventeen Stars

Re: Issue with JAR files when using a custom component

In case of having trouble with jars in user components:
It depends on the way how to get the studio your component.
In case you use the Component designer perspective and use the function Push Component to Palette: I this case: use this function more than once, I do not know why but only once does not deploy the jars not correctly.
At first find your component in the user component folder.
You can put your component also be hand in this folder and in this case open the Preferences->Talend->Components and click on Apply. Now the components from this folder will be copied and the Generation Engine starts again. This works only once. If you want to do this a second time you have to restart the studio.
In case of studio does not "want" your jar, please close studio, delete the file ComponentCache.javacache in the configuration sub dir in your studio and start studio again. This delete causes a rescan of all libraries and mostly they find now your jars also.
One Star

Re: Issue with JAR files when using a custom component

Hi jlolling,,
I am new to Talend Open Studio, just I have downloaded Version: 5.6.0M1(Build id: r118307-20140604-0708), and I tried to build a simple Java custom component import with custom logic Test.jar.
 
I copied tReplace and  import Test.Jar, tried to create object  for our custom class like com.org.TestCls t=new com.org.TestCls()
 
When run job with tReplace component, getting below error
 
xecution failed : Failed to generate code.

 
I have tried adding a tLibraryLoad node with the jar specified in the basic settings
 
Not  working  kindly help me