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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
pashworth
Contributor III
Contributor III

[resolved] Component Compile Error using external libraries

I've created a new component, set all the paramaters etc.
In the code I want to refer to some libraries.
I've included these as part of the component creation and the statements are in the code generation stuff.
But if I add anything to the jet imports and try to push the component it just says there are compiles errors in the begin jet.
As the additional import is the only thing added I'm not sure what I've done wrong.
<%@ jet
imports="
org.talend.core.model.process.INode
.....
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
java.util.List
java.util.Map
com.hp.hpl.jena.rdf.model.*
"
%>
I've also tried referring to specifics as well com.hp.hpl.jena.rdf.model.Model
but it still gives this error.
.
The jar has been added in the lib java folder
I can use the import in routines without issue.... I just can't get my component to compile if I use an import.
Please help
Labels (4)
1 Solution

Accepted Solutions
pashworth
Contributor III
Contributor III
Author

Ah belay that. I think I've seen my error.... I don't need to import it i the jet imports

View solution in original post

5 Replies
pashworth
Contributor III
Contributor III
Author

Ah belay that. I think I've seen my error.... I don't need to import it i the jet imports
pashworth
Contributor III
Contributor III
Author

No still getting errors.
Saying that things can't be resolved. It looks like it can't see the llibraires.
Anyone help?
Phil
Anonymous
Not applicable

It depends what you want to do with your lib. If you want use java code running at the design time of of the job (like wizards) it is necessary to add them as plugin to Talend.
If the lib contains java code which should be used in the runtime of the job, it is quite enough to add your library in the XML in the codegeneration tag as import (use the code completion to have a body for it).
pashworth
Contributor III
Contributor III
Author

Hi jlolling
I have declared the library in the xml as part of using the component creation wizard.
it created the following entry in the xml and copied the .jar to the lib/java folder.
<CODEGENERATION>
<IMPORTS>
<IMPORT MODULE="jena-core-2.10.1.jar" NAME="jena-core-2.10.1" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
In my begin code I want to instantiate an object from the library.
such as
// create an empty model
Model model_<%=cid %> = ModelFactory.createDefaultModel();
.....
I can push the component to the palette with out error.
I can bring the component into a job
but when I run the job i get an error
saying "Model cannot be resolved to a type"
The code I am using in the begin works fine in a routine. but there I am explicitly adding an import to the class.
I just cannot get it to work in a component.
Any thoughts?
Cheers
Phil
pashworth
Contributor III
Contributor III
Author

I see one of my errors
I needed to be more explicit e.g.
com.hp.hpl.jena.rdf.model.Model model_<%=cid %> = com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel();
Now it can resolve all the types correctly but now when trying to run the component i get

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
I have added slf4j-api-1.6.4.jar to the xml code gen imports tags
copied the jar to lib java.
but I still can't get past this one.
I'm not calling directly myself so it must be Talend or the classes I am creating.
There seems to be a bit about this on talend jira but I can't see what is causing it.
Help Please !
Cheers
Phil