One Star

Can't use custom routines in exported jobs

I'm having issues with custom routines. When running in Open Studio everything works fine. When I export the job and run the resulting batch file, I get Java.NoClassDefFoundError exceptions.
As an example, I set up a simple project and created a custom routine
public class TestRoutines {
public static int doubleInt(int x)
return x*2;

I then created a job containing only a java component with the following code (also included import.TestRoutines in the advanced tab)
for(int i = 1;i<=10;i++)

Running this in Talend produces the desired output.
If I run it from the comand line I get the following exception:
c:\testinput_0.1\testinput>java -Xms256M -Xmx1024M -cp classpath.jar; testoracle
.testinput_0_1.testinput --context=Default
Exception in thread "main" java.lang.Error: java.lang.NoClassDefFoundError: rout
at testoracle.testinput_0_1.testinput.tJava_1Process(
at testoracle.testinput_0_1.testinput.runJobInTOS(
at testoracle.testinput_0_1.testinput.main(
Caused by: java.lang.NoClassDefFoundError: routines/TestRoutines
at testoracle.testinput_0_1.testinput.tJava_1Process(
... 2 more
Caused by: java.lang.ClassNotFoundException: routines.TestRoutines
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more

As we use the windows scheduling service to run our jobs, this causes some issues. I'm using 4.1.0.M3_r46036.
Anyone have a clue as to what could be wrong?
One Star

Re: Can't use custom routines in exported jobs

There is a jar file called userRoutines.jar that is exported when you export your talend job. It is under lib directory.
Your cutomized routine is in this jar. This jar needs to be deployed/re-deployed along with your job jars.
One Star

Re: Can't use custom routines in exported jobs

System routines work fine and that jar is in lib.
I've copied userRoutines.jar into the same directory as testinput_0_1.jar - same error.
I've copied the lib directory into the same directory as testinput_0_1.jar - same error.
Also looking inside the classpath.jar file I find
Manifest-Version: 1.0
Implementation-Vendor: Talend Open Studio
Class-Path: testinput_0_1.jar ../lib/systemRoutines.jar ../lib/userRou
tines.jar ../Rules/

which suggests that userRoutines.jar is visible to the executable?
useRoutines.jar isn't being built properly. There is only a META-INF folder with the file inside it.
One Star

Re: Can't use custom routines in exported jobs

Got it working.
Right clicking on the job and selecting "Set up routine dependencies" to add the user routines caused the jar file to be built correctly.
One Star

Re: Can't use custom routines in exported jobs

Glad to know it is working now. "Set up routine dependencies" must be new in version 4.1.0. I am still using version 3.2.1. I don't see it in my Talend Studio ( or maybe it is hiding somewhere else).