Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] New custom component does not recognise library (v.5.0.1)

Hi,
I'm creating a new component and included the api of the application I want to integrate to. None of the classes I reference can be resolved by the component.
I have read subaro's EXCELLENT tutorial, seen all Carl's youtube tutorials, Google'd all I could about the issues I'm experiencing, and find myself a little daft for not being able to achieve.
Windows 7 Professional SP1
Talend Open Studio for ESB
Version: 5.0.1
Build id: r74687-20111216-0210
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)

Error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
com.bmc cannot be resolved to a type
com.bmc cannot be resolved to a type
com.bmc.arsys.api.Constants cannot be resolved to a variable

tRemedyTest_begin.javajet
<%@ jet 
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.core.model.process.IConnection
org.talend.core.model.process.IConnectionCategory
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
java.util.List
java.util.Map
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String arserver = ElementParameterParser.getValue(node, "__ARSERVER__");
String username = ElementParameterParser.getValue(node, "__USERNAME__");
String password = ElementParameterParser.getValue(node, "__PASSWORD__");

%>
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
com.bmc.arsys.api.ARServerUser aruser_<%=cid%> = new com.bmc.arsys.api.ARServerUser("<%=username%>", "<%=password%>", "", "<%=arserver%>");
String sysname = com.bmc.arsys.api.Constants.AR_SYSTEM_NAME;
System.out.println(sysname);

tRemedyTest_java.xml
<?xml version="1.0" encoding="UTF-8"?>
<COMPONENT>
<HEADER AUTHOR="Me" RELEASE_DATE="20111220A" COMPATIBILITY="ALL"
PLATEFORM="ALL" SERIAL="" VERSION="0.102" STATUS="ALPHA" STARTABLE="true">
<SIGNATURE/>
</HEADER>

<FAMILIES>
<FAMILY>Application/BMC/Remedy</FAMILY>
</FAMILIES>

<DOCUMENTATION>
<URL></URL>
</DOCUMENTATION>

<CONNECTORS>
<CONNECTOR CTYPE="FLOW"/>
</CONNECTORS>

<PARAMETERS>
<PARAMETER NAME="ARSERVER" FIELD="TEXT" REQUIRED="true" NUM_ROW ="1" />
<PARAMETER NAME="USERNAME" FIELD="TEXT" REQUIRED="true" NUM_ROW ="2" />
<PARAMETER NAME="PASSWORD" FIELD="TEXT" REQUIRED="true" NUM_ROW ="2" />
<PARAMETER NAME="AUTH" FIELD="TEXT" REQUIRED="false" NUM_ROW ="3" />
<PARAMETER NAME="SCHEMA" FIELD="SCHEMA_TYPE" REQUIRED="true" NUM_ROW="4"/>
</PARAMETERS>

<ADVANCED_PARAMETERS>
<PARAMETER NAME="DESC" FIELD="CHECK" REQUIRED="false" NUM_ROW ="1" />
<PARAMETER NAME="REPL" FIELD="CHECK" REQUIRED="false" NUM_ROW ="2" />
<PARAMETER NAME="UND" FIELD="CHECK" REQUIRED="false" NUM_ROW ="3" />
<PARAMETER NAME="LAB" FIELD="CHECK" REQUIRED="false" NUM_ROW ="4" />
<PARAMETER NAME="PORT" FIELD="INT" REQUIRED="false" NUM_ROW ="5" />
<PARAMETER NAME="RPC" FIELD="INT" REQUIRED="false" NUM_ROW ="6" />
</ADVANCED_PARAMETERS>

<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="arapi7604" MODULE="arapi7604.jar" REQUIRED="true" />
<IMPORT NAME="log4j" MODULE="log4j-1.2.14.jar" REQUIRED="true" />
</IMPORTS>
</CODEGENERATION>
<RETURNS>
<RETURN NAME="NB_LINE" TYPE="id_Integer" AVAILABILITY="AFTER"/>
</RETURNS>
</COMPONENT>

arapi7604.jar is in the component directory.
public abstract interface com.bmc.arsys.api.Constants {
public static final java.lang.String AR_SYSTEM_NAME = "Action Request System";
}
public class com.bmc.arsys.api.ARServerUser {
public ARServerUser(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3);
}

Help would be greatly appreciated.
Kind regards,
Johan.
Labels (5)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi there,
You need to configure your component to declare the dependency on the jar file in an XML section something like this:
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="RequiredLib" MODULE="requiredlib-1.2.3.jar" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
The 3rd party jar(s) should also be included in the Studio as external libraries. There are two ways to do this - manually deploy the jar to the studios lib/java folder, or letting it happen automatically as part of your component deployment/distribution.
For internal use, bundling the jar with your component may be convenient, but if you want to share your component and the JAR is covered by a 3rd party license that prevents distribution then this may not be an option for you. In that case each component user would provide their own JARs.
You should find more discussion/detail on these points in this thread: https://community.talend.com/t5/Design-and-Development/creation-component-import-java-libraries/td-p...
HTH

View solution in original post

5 Replies
Anonymous
Not applicable
Author

Hi there,
You need to configure your component to declare the dependency on the jar file in an XML section something like this:
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="RequiredLib" MODULE="requiredlib-1.2.3.jar" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
The 3rd party jar(s) should also be included in the Studio as external libraries. There are two ways to do this - manually deploy the jar to the studios lib/java folder, or letting it happen automatically as part of your component deployment/distribution.
For internal use, bundling the jar with your component may be convenient, but if you want to share your component and the JAR is covered by a 3rd party license that prevents distribution then this may not be an option for you. In that case each component user would provide their own JARs.
You should find more discussion/detail on these points in this thread: https://community.talend.com/t5/Design-and-Development/creation-component-import-java-libraries/td-p...
HTH
Anonymous
Not applicable
Author

Thank you irahman,
as you can see from the code snippets I included, I have declared the jar file in the XML section, it is also included in my component directory.
When I copy the jar to <Talend_home>/lib/java it is recognized, but it's not recognized from within my components directory (where the .xml and .javajet files are located).
So if I would want to share my component it will not run unless the jar files are duplicated to the <Talend_home>/lib/java directory.
Kind regards,
Johan Wasserman.
Anonymous
Not applicable
Author

Update:
When I quit Open Studio and start it up again, my code works. If I make any code changes and push the component to the Palette, my jar's aren't recognized, I have to quit Open Studio and start it up again to test the code changes.
This may be a bug in the version of Open Studio I have, I'll install an older version of Open Studio and see if that works.
Kind regards,
Johan Wasserman.
Anonymous
Not applicable
Author

Works in Open Studio Version: 4.2.3 with the jars only in my component directory (not in <Talend_home>/lib/java).
Suggest this may be a bug in 5.0.1
Kind regards,
Johan.
Anonymous
Not applicable
Author

Agreed - it does sound like a possible regression, though it doesn't occur in all cases as I have a custom component in 5.0.1, and my jar is being deployed from the component folder to lib/java automatically, and being recognised.
The 'Modules' view might give you more insight into what the Studio thinks is going on. It will show if the jar is installed or not.
If this issue is reliably reproducible (sounds like it is) then could you report it in JIRA?