Can't use custom routines in exported jobs

One Star

Can't use custom routines in exported jobs

Hi,
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++)
{
System.out.println(TestRoutines.doubleInt(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
ines/TestRoutines
at testoracle.testinput_0_1.testinput.tJava_1Process(testinput.java:268)
at testoracle.testinput_0_1.testinput.runJobInTOS(testinput.java:415)
at testoracle.testinput_0_1.testinput.main(testinput.java:313)
Caused by: java.lang.NoClassDefFoundError: routines/TestRoutines
at testoracle.testinput_0_1.testinput.tJava_1Process(testinput.java:230)
... 2 more
Caused by: java.lang.ClassNotFoundException: routines.TestRoutines
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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
c:\testinput_0.1\testinput>

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?
Thanks
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 manifest.mf 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).