Trying to import jar into custom component

One Star

Trying to import jar into custom component

I've started creating a custom component for inserting raw java objects into a mongodb using the morphia library. I started with the tMongoDBOutput as a base and stripped out all the code that I didn't need. After I successfully did this I tried to import some Morphia packages in my code but I keep getting this error at run time:

1. ERROR in /home/jordan/development/talend-bd/workspace/.JETEmitters/src/org/talend/designer/codegen/translators/gd/itno/TMorphiaOutputBeginJava.java (at line 9)
import org.mongodb.morphia.Datastore;
      ^^^^^^^^^^^
The import org.mongodb cannot be resolved



I have the necessary IMPORT lines in my tMorphiaOutput_java.xml file (The jars is in the same directory as all the component files):

<IMPORT MODULE="morphia-1.1.0-SNAPSHOT.jar" NAME="morphia-1.1.0-SNAPSHOT" REQUIRED="true"/> 


And the import statement in my tMorphiaOutput_begin.javajet:

<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.List
java.util.Map
org.mongodb.morphia.Datastore
org.mongodb.morphia.Morphia
"
%>


I've searched but these are the only things that I can find that are required to use an external jar in a custom component but I still get that very vague error.
Anyone run into this, or know what I'm missing?

One Star

Re: Trying to import jar into custom component

Now I've tried taking the import out of the import section of the javajet file and put the full classpath in the code but I'm getting the same sort of error:
1. ERROR in /home/jordan/development/talend-bd/workspace/.JETEmitters/src/org/talend/designer/codegen/translators/gd/itno/TMorphiaOutputBeginJava.java (at line 119)
org.mongodb.morphia.Morphia morphia = new org.mongodb.morphia.Morphia();
^^^^^^^^^^^
org.mongodb cannot be resolved to a type

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog