Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
In my job I used to call a routine in my tMap to construct a String with some informations I have (or not) in my input rows.
I call my routine function like and I use different attibutes inside the function.
Utils.getLigneBulk(row8, row9, row10)
import project_name.job_name_0_1.JOB.row8Struct;
import project_name.job_name_0_1.JOB.row9Struct;
import project_name.job_name_0_1.JOB.row10Struct;
....
public static String getLigneBulk(row8Struct row8,row9Struct row9, row10Struct row10) {
// ....
}
But I have a problem in the routine with the classes and imports because it's refers to a missing type row8Struct (and I suppose it's the same for row9Struct and row10Struct).
However this worked in my previous job version on V6.x but not now in v8.x. Maybe I forgot some things.
Thanks for any advises.
Best regards.
Antho
The problem here is the class for a row e.g. row8Struc is defined inside the job as inner class. A routine must be compilable outside of a job thats why you cannot directly use these class.
In Talend Open Studio v6 the code generation was different and the job classes and the classes from the routines was inside of one huge Java project. Since Talend 7 all jobs are its own Maven projects and the formally existing one huge Java project does not exists anymore.
If you want using this kind of object the only way is using reflection API (part of JDK).
Please note the routines will be compiled separately to its own jar. There is no context of a job to compile these classes.
What you also can do is, not writing a routine, instead write an inner class inside the job using tJavaFlex. You can always define your class in the Begin section of a tJavaFlex and use it in the flow if the tJavaFlex.
I am not sure this way will work. However, you should add the dependency jar file which contain the classes you import to the routine.
Regards
Shicong
Thanks for the answer but I'm not sure to understand where add the depedency because the classes are in the same job where I call the routine.
Here a picture of my job to have a better view (the routine function call is made in the tMap_3 using other inputs datas).
Best regards
The problem here is the class for a row e.g. row8Struc is defined inside the job as inner class. A routine must be compilable outside of a job thats why you cannot directly use these class.
In Talend Open Studio v6 the code generation was different and the job classes and the classes from the routines was inside of one huge Java project. Since Talend 7 all jobs are its own Maven projects and the formally existing one huge Java project does not exists anymore.
If you want using this kind of object the only way is using reflection API (part of JDK).
Please note the routines will be compiled separately to its own jar. There is no context of a job to compile these classes.
What you also can do is, not writing a routine, instead write an inner class inside the job using tJavaFlex. You can always define your class in the Begin section of a tJavaFlex and use it in the flow if the tJavaFlex.
Again, this will not work anymore. See my former comment about the reason. Use reflection api or use an inner class using the tJavaFlex component. You can put the tJavaFlex component between tUniqueRow_2 and tMap and class your routine class in the main part of the tJavaFlex.
Thanks @jlolling for explanations and especially for the differences between v6 and v8 code generation.
My other idea was to use tJava or tJavaFlex to do some of my routine function work, so your post confirms this. I will try.
Thanks again.