How to include multiple runtime JAR files with a Job

Overview

There are two ways to include one or more JAR files with a Job:

  1. tLibraryLoad—Use a tLibraryLoad component to load a single JAR (or multiple JARs, using the Advanced settings tab), or
  2. Routine Libraries—Set a code routine as a dependency of your Job, and include libraries on that routine.

 

Problem Description

When running a Job, you may get one of the following errors:

java.lang.NoClassDefFoundError

or

java.lang.ClassNotFoundException

 

For example:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/drill/exec/rpc/RpcException
at com.mapr.drill.core.DRJDBCConnection.connect(Unknown Source)
at com.mapr.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
at com.mapr.jdbc.common.AbstractDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at acme.drill_test_0_1.drill_test.tJDBCConnection_1Process(drill_test.java:411)
at acme.drill_test_0_1.drill_test.runJobInTOS(drill_test.java:1262)

 

Diagnosis

Job (an executable Java class) is not able to find a class in its classpath.

 

Solutions

 

tLibraryLoad

  1. Add a tLibraryLoad component to your Job.
  2. Select the first JAR file you need to load in the Library drop-down list (use the ... Browse selector if you need to).
  3. Click Advanced settings.
  4. Click the + (Add JAR) button and type the filename (not the full path) of the JAR you need to add, for example "sqljdbc42.jar". Note that you must use the double quotes.
  5. Repeat the above step for all the JAR files the Job needs.
  6. Run the Job.
  7. Studio will prompt you to locate/load all the required Jobs it cannot find.
  8. Studio will finish loading JAR files and will run the Job.

 

load-multiple-jars-with-tlibraryload-component.png

 

Routine Libraries

Right-click a routine you use in your Job and select Edit routine libraries, then add the JAR files you need.

 

Even if you do not use any routines in your Job, you can still use this method.

  1. Create a routine in Code > Routines called JarHolderRoutine (or any name you wish).
  2. Add the JAR files you need. The screenshot below shows the various popups you will see when adding a new JAR to your routine as a Routine Library.

     

    code-routines-edit-routing-libraries.png

     

  3. Link the routine to your Job:

    1. Close your Job.
    2. Right-click the Job, then select Setup routine dependencies.
    3. Click + to add the new JarHolderRoutine routine.
Version history
Revision #:
8 of 8
Last update:
‎06-06-2018 06:37 AM
Updated by:
 
Labels (2)
Contributors